 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
19 using namespace std::chrono_literals;
27 void GenerateTemplateResults(
const std::vector<ankerl::nanobench::Result>& benchmarkResults,
const fs::path& file,
const char* tpl)
29 if (benchmarkResults.empty() || file.empty()) {
33 std::ofstream fout{file};
36 std::cout <<
"Created " << file << std::endl;
38 std::cout <<
"Could not write to file " << file << std::endl;
46 static std::map<std::string, BenchFunction> benchmarks_map;
47 return benchmarks_map;
52 benchmarks().insert(std::make_pair(
name, func));
57 std::regex reFilter(
args.regex_filter);
58 std::smatch baseMatch;
60 std::vector<ankerl::nanobench::Result> benchmarkResults;
61 for (
const auto& p : benchmarks()) {
62 if (!std::regex_match(p.first, baseMatch, reFilter)) {
66 if (
args.is_list_only) {
67 std::cout << p.first << std::endl;
73 if (
args.min_time > 0ms) {
75 std::chrono::nanoseconds min_time_ns =
args.min_time;
79 if (
args.asymptote.empty()) {
82 for (
auto n :
args.asymptote) {
89 if (!bench.results().empty()) {
90 benchmarkResults.push_back(bench.results().back());
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"
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.
static void RunAll(const Args &args)
Main entry point to nanobench's benchmarking facility.
std::function< void(Bench &)> BenchFunction
std::vector< BigO > complexityBigO() const
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
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::map< std::string, BenchFunction > BenchmarkMap
Bench & epochs(size_t numEpochs) noexcept
Controls number of epochs, the number of measurements to perform.
const std::function< std::vector< const char * >)> G_TEST_COMMAND_LINE_ARGUMENTS
Retrieve the command line arguments.
const std::function< void(const std::string &)> G_TEST_LOG_FUN
This is connected to the logger.