diff --git a/src/bench/bench.h b/src/bench/bench.h --- a/src/bench/bench.h +++ b/src/bench/bench.h @@ -14,6 +14,10 @@ #include #include +struct RegTestingSetup; +//! A pointer to the current testing setup +extern const RegTestingSetup *g_testing_setup; + // Simple micro-benchmarking framework; API mostly matches a subset of the // Google Benchmark framework (see https://github.com/google/benchmark) // Why not use the Google Benchmark framework? Because adding Yet Another diff --git a/src/bench/bench.cpp b/src/bench/bench.cpp --- a/src/bench/bench.cpp +++ b/src/bench/bench.cpp @@ -16,6 +16,8 @@ #include #include +const RegTestingSetup *g_testing_setup = nullptr; + void benchmark::ConsolePrinter::header() { std::cout << "# Benchmark, evals, iterations, total, min, max, median" << std::endl; @@ -149,6 +151,8 @@ for (const auto &p : benchmarks()) { RegTestingSetup test{}; + assert(g_testing_setup == nullptr); + g_testing_setup = &test; assert(::ChainActive().Height() == 0); if (!std::regex_match(p.first, baseMatch, reFilter)) { @@ -165,6 +169,7 @@ p.second.func(state); } printer.result(state); + g_testing_setup = nullptr; } printer.footer(); diff --git a/src/bench/block_assemble.cpp b/src/bench/block_assemble.cpp --- a/src/bench/block_assemble.cpp +++ b/src/bench/block_assemble.cpp @@ -7,6 +7,7 @@ #include #include