8 #include <test/util/setup_common.h> 9 #include <validation.h> 17 void GenerateTemplateResults(
const std::vector<ankerl::nanobench::Result>& benchmarkResults,
const std::string& filename,
const char* tpl)
19 if (benchmarkResults.empty() || filename.empty()) {
27 std::cout <<
"Could write to file '" << filename <<
"'" << std::endl;
30 std::cout <<
"Created '" << filename <<
"'" << std::endl;
37 static std::map<std::string, BenchFunction> benchmarks_map;
38 return benchmarks_map;
43 benchmarks().insert(std::make_pair(name, func));
49 std::smatch baseMatch;
51 std::vector<ankerl::nanobench::Result> benchmarkResults;
53 if (!std::regex_match(p.first, baseMatch, reFilter)) {
58 std::cout << p.first << std::endl;
74 if (!bench.results().empty()) {
75 benchmarkResults.push_back(bench.results().back());
79 GenerateTemplateResults(benchmarkResults, args.
output_csv,
"# Benchmark, evals, iterations, total, min, max, median\n" 80 "{{#result}}{{name}}, {{epochs}}, {{average(iterations)}}, {{sumProduct(iterations, elapsed)}}, {{minimum(elapsed)}}, {{maximum(elapsed)}}, {{median(elapsed)}}\n" char const * json() noexcept
Template to generate JSON data.
BenchRunner(std::string name, BenchFunction func)
std::vector< double > asymptote
const std::function< void(const std::string &)> G_TEST_LOG_FUN
void render(char const *mustacheTemplate, Bench const &bench, std::ostream &out)
Renders output from a mustache-like template and benchmark results.
ANKERL_NANOBENCH(NODISCARD) std Bench & name(char const *benchmarkName)
Name of the benchmark, will be shown in the table row.
std::vector< BigO > complexityBigO() const
Bench & complexityN(T b) noexcept
std::function< void(Bench &)> BenchFunction
std::map< std::string, BenchFunction > BenchmarkMap
static void RunAll(const Args &args)
static BenchmarkMap & benchmarks()
Main entry point to nanobench's benchmarking facility.