|
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
18 using namespace std::chrono_literals;
24 void GenerateTemplateResults(
const std::vector<ankerl::nanobench::Result>& benchmarkResults,
const std::string& filename,
const char* tpl)
26 if (benchmarkResults.empty() || filename.empty()) {
34 std::cout <<
"Could write to file '" << filename <<
"'" << std::endl;
37 std::cout <<
"Created '" << filename <<
"'" << std::endl;
44 static std::map<std::string, BenchFunction> benchmarks_map;
45 return benchmarks_map;
50 benchmarks().insert(std::make_pair(
name, func));
56 std::smatch baseMatch;
58 std::vector<ankerl::nanobench::Result> benchmarkResults;
59 for (
const auto& p : benchmarks()) {
60 if (!std::regex_match(p.first, baseMatch, reFilter)) {
65 std::cout << p.first << std::endl;
73 std::chrono::nanoseconds min_time_ns = args.
min_time;
87 if (!bench.results().empty()) {
88 benchmarkResults.push_back(bench.results().back());
92 GenerateTemplateResults(benchmarkResults, args.
output_csv,
"# Benchmark, evals, iterations, total, min, max, median\n"
93 "{{#result}}{{name}}, {{epochs}}, {{average(iterations)}}, {{sumProduct(iterations, elapsed)}}, {{minimum(elapsed)}}, {{maximum(elapsed)}}, {{median(elapsed)}}\n"
void render(char const *mustacheTemplate, Bench const &bench, std::ostream &out)
Renders output from a mustache-like template and benchmark results.
const std::function< void(const std::string &)> G_TEST_LOG_FUN
This is connected to the logger.
ANKERL_NANOBENCH(NODISCARD) std Bench & name(char const *benchmarkName)
Name of the benchmark, will be shown in the table row.
static void RunAll(const Args &args)
std::chrono::milliseconds min_time
Main entry point to nanobench's benchmarking facility.
std::function< void(Bench &)> BenchFunction
std::vector< BigO > complexityBigO() const
static BenchmarkMap & benchmarks()
ANKERL_NANOBENCH(NODISCARD) std Bench & minEpochTime(std::chrono::nanoseconds t) noexcept
Minimum time each epoch should take.
Bench & complexityN(T b) noexcept
BenchRunner(std::string name, BenchFunction func)
char const * json() noexcept
Template to generate JSON data.
std::vector< double > asymptote
std::map< std::string, BenchFunction > BenchmarkMap
Bench & epochs(size_t numEpochs) noexcept
Controls number of epochs, the number of measurements to perform.