<commit_before>//-----------------------------------------------------------------------------
// HIMG, by <NAME>, 2015
//
// This is free and unencumbered software released into the public domain.
//
// See LICENSE for details.
//-----------------------------------------------------------------------------

#include <chrono>
#include <cstdint>
#include <fstream>
#include <iostream>

#include <FreeImage.h>

#include "decoder.h"
#include "encoder.h"

namespace {

const int kNumIterations = 30;

enum BenchmarkMode {
  Decode,
  Encode
};

class TimeMeasure {
 public:
  void Start() { m_start = std::chrono::system_clock::now(); }

  double Duration() const {
    std::chrono::system_clock::time_point t = std::chrono::system_clock::now();
    return static_cast<double>(
        std::chrono::duration_cast<std::chrono::milliseconds>(t - m_start)
            .count());
  }

 private:
  std::chrono::system_clock::time_point m_start;
};

bool IsHimg(const std::vector<uint8_t> &buffer) {
  return buffer.size() >= 12 && buffer[0] == 'R' && buffer[1] == 'I' &&
         buffer[2] == 'F' && buffer[3] == 'F' && buffer[8] == 'H' &&
         buffer[9] == 'I' && buffer[10] == 'M' && buffer[11] == 'G';
}

void ShowUsage(const char *arg0) {
  std::cout << "Usage: " << arg0 << " [-d][-e] image" << std::endl;
  std::cout << "  -d Decode (default)" << std::endl;
  std::cout << "  -e Encode" << std::endl;
}

bool LoadFile(const std::string &file_name, std::vector<uint8_t> *buffer) {<commit_msg>More accurate benchmark measurements<commit_after>//-----------------------------------------------------------------------------
// HIMG, by <NAME>, 2015
//
// This is free and unencumbered software released into the public domain.
//
// See LICENSE for details.
//-----------------------------------------------------------------------------

#include <chrono>
#include <cstdint>
#include <fstream>
#include <iostream>

#include <FreeImage.h>

#include "decoder.h"
#include "encoder.h"

namespace {

const int kNumIterations = 30;

enum BenchmarkMode {
  Decode,
  Encode
};

class TimeMeasure {
 public:
  void Start() { m_start = std::chrono::system_clock::now(); }

  double Duration() const {
    std::chrono::system_clock::time_point t = std::chrono::system_clock::now();
    return static_cast<double>(
               std::chrono::duration_cast<std::chrono::microseconds>(
                   t - m_start).count()) /
           1000.0;
  }

 private:
  std::chrono::system_clock::time_point m_start;
};

bool IsHimg(const std::vector<uint8_t> &buffer) {
  return buffer.size() >= 12 && buffer[0] == 'R' && buffer[1] == 'I' &&
         buffer[2] == 'F' && buffer[3] == 'F' && buffer[8] == 'H' &&
         buffer[9] == 'I' && buffer[10] == 'M' && buffer[11] == 'G';
}

void ShowUsage(const char *arg0) {
  std::cout << "Usage: " << arg0 << " [-d][-e] image" << std::endl;
  std::cout << "  -d Decode (default)" << std::endl;
  std::cout << "  -e Encode" << std::endl;
}

bool LoadFile(const std::string &file_name, std::vector<uint8_t> *buffer) {
{'fraction_non_alphanumeric': 0.277175697865353, 'fraction_numerical': 0.016091954022988506, 'mean_word_length': 2.44180790960452, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 25, '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': '64698', 'n_tokens_mistral': 1024, 'n_tokens_neox': 979, 'n_words': 228}