File: benchmark.cpp

package info (click to toggle)
inja 3.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,620 kB
  • sloc: cpp: 30,997; python: 189; makefile: 16; sh: 3
file content (31 lines) | stat: -rw-r--r-- 1,054 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (c) 2020 Pantor. All rights reserved.

#include <hayai/hayai.hpp>
#include <inja/inja.hpp>

inja::Environment env;

const std::filesystem::path test_file_directory {"../test/data/benchmark/"};

const auto small_data = env.load_json((test_file_directory / "small_data.json").string());
const auto large_data = env.load_json((test_file_directory / "large_data.json").string());
const std::string medium_template = env.load_file((test_file_directory / "medium_template.txt").string());
const std::string large_template = env.load_file((test_file_directory / "large_template.txt").string());

BENCHMARK(SmallDataMediumTemplate, render, 5, 30) {
  env.render(medium_template, small_data);
}
BENCHMARK(LargeDataMediumTemplate, render, 5, 15) {
  env.render(medium_template, large_data);
}
BENCHMARK(LargeDataLargeTemplate, render, 5, 5) {
  env.render(large_template, large_data);
}

int main() {
  hayai::ConsoleOutputter consoleOutputter;

  hayai::Benchmarker::AddOutputter(consoleOutputter);
  hayai::Benchmarker::RunAllTests();
  return 0;
}