<commit_before>#include <kernel/os.hpp>
#include <liveupdate>
#include <timers>
using namespace liu;

static std::vector<int64_t> timestamps;
static buffer_t bloberino;

static void boot_save(Storage& storage, const buffer_t* blob)
{
  timestamps.push_back(OS::nanos_since_boot());
  storage.add_vector(0, timestamps);
  assert(blob != nullptr);
  storage.add_buffer(2, *blob);
}
static void boot_resume_all(Restore& thing)
{
  timestamps = thing.as_vector<int64_t>(); thing.go_next();
  // calculate time spent
  auto t1 = timestamps.back();
  auto t2 = OS::nanos_since_boot();
  // set final time
  timestamps.back() = t2 - t1;
  // retrieve old blob
  bloberino = thing.as_buffer(); thing.go_next();

  thing.pop_marker();
}

LiveUpdate::storage_func begin_test_boot()
{
  if (LiveUpdate::resume("test", boot_resume_all))
  {
    if (timestamps.size() >= 30)
    {
      // calculate median by sorting
      std::sort(timestamps.begin(), timestamps.end());
      auto median = timestamps[timestamps.size()/2];
      // show information
      printf("Median boot time over %lu samples: %.2f millis\n",<commit_msg>test: Verify OS sees it was live updated after live updates<commit_after>#include <kernel/os.hpp>
#include <liveupdate>
#include <timers>
using namespace liu;

static std::vector<int64_t> timestamps;
static buffer_t bloberino;

static void boot_save(Storage& storage, const buffer_t* blob)
{
  timestamps.push_back(OS::nanos_since_boot());
  storage.add_vector(0, timestamps);
  assert(blob != nullptr);
  storage.add_buffer(2, *blob);
}
static void boot_resume_all(Restore& thing)
{
  timestamps = thing.as_vector<int64_t>(); thing.go_next();
  // calculate time spent
  auto t1 = timestamps.back();
  auto t2 = OS::nanos_since_boot();
  // set final time
  timestamps.back() = t2 - t1;
  // retrieve old blob
  bloberino = thing.as_buffer(); thing.go_next();

  thing.pop_marker();
}

LiveUpdate::storage_func begin_test_boot()
{
  if (LiveUpdate::resume("test", boot_resume_all))
  {
    // OS must be able to tell it was live updated each time
    assert(OS::is_live_updated());

    if (timestamps.size() >= 30)
    {
      // calculate median by sorting
      std::sort(timestamps.begin(), timestamps.end());
      auto median = timestamps[timestamps.size()/2];
      // show information
      printf("Median boot time over %lu samples: %.2f millis\n",
{'fraction_non_alphanumeric': 0.1390644753476612, 'fraction_numerical': 0.011799410029498525, 'mean_word_length': 4.275555555555556, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1453926', 'n_tokens_mistral': 826, 'n_tokens_neox': 819, 'n_words': 192}