| 53 | } |
| 54 | |
| 55 | void benchmark::BenchRunner::RunAll(const Args& args) |
| 56 | { |
| 57 | std::regex reFilter(args.regex_filter); |
| 58 | std::smatch baseMatch; |
| 59 | |
| 60 | std::vector<ankerl::nanobench::Result> benchmarkResults; |
| 61 | for (const auto& p : benchmarks()) { |
| 62 | if (!std::regex_match(p.first, baseMatch, reFilter)) { |
| 63 | continue; |
| 64 | } |
| 65 | |
| 66 | if (args.is_list_only) { |
| 67 | std::cout << p.first << std::endl; |
| 68 | continue; |
| 69 | } |
| 70 | |
| 71 | Bench bench; |
| 72 | bench.name(p.first); |
| 73 | if (args.min_time > 0ms) { |
| 74 | // convert to nanos before dividing to reduce rounding errors |
| 75 | std::chrono::nanoseconds min_time_ns = args.min_time; |
| 76 | bench.minEpochTime(min_time_ns / bench.epochs()); |
| 77 | } |
| 78 | |
| 79 | if (args.asymptote.empty()) { |
| 80 | p.second(bench); |
| 81 | } else { |
| 82 | for (auto n : args.asymptote) { |
| 83 | bench.complexityN(n); |
| 84 | p.second(bench); |
| 85 | } |
| 86 | std::cout << bench.complexityBigO() << std::endl; |
| 87 | } |
| 88 | |
| 89 | if (!bench.results().empty()) { |
| 90 | benchmarkResults.push_back(bench.results().back()); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | GenerateTemplateResults(benchmarkResults, args.output_csv, "# Benchmark, evals, iterations, total, min, max, median\n" |
| 95 | "{{#result}}{{name}}, {{epochs}}, {{average(iterations)}}, {{sumProduct(iterations, elapsed)}}, {{minimum(elapsed)}}, {{maximum(elapsed)}}, {{median(elapsed)}}\n" |
| 96 | "{{/result}}"); |
| 97 | GenerateTemplateResults(benchmarkResults, args.output_json, ankerl::nanobench::templates::json()); |
| 98 | } |
nothing calls this directly
no test coverage detected