diff --git a/src/bench/bench.h b/src/bench/bench.h --- a/src/bench/bench.h +++ b/src/bench/bench.h @@ -14,10 +14,6 @@ #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,8 +16,6 @@ #include #include -const RegTestingSetup *g_testing_setup = nullptr; - void benchmark::ConsolePrinter::header() { std::cout << "# Benchmark, evals, iterations, total, min, max, median" << std::endl; @@ -150,13 +148,7 @@ printer.header(); 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)) { - g_testing_setup = nullptr; continue; } @@ -170,7 +162,6 @@ 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 @@ -16,6 +16,7 @@ static void AssembleBlock(benchmark::State &state) { const Config &config = GetConfig(); + RegTestingSetup test_setup; const CScript redeemScript = CScript() << OP_DROP << OP_TRUE; const CScript SCRIPT_PUB = @@ -31,8 +32,7 @@ std::array txs; for (size_t b = 0; b < NUM_BLOCKS; ++b) { CMutableTransaction tx; - tx.vin.push_back( - MineBlock(config, g_testing_setup->m_node, SCRIPT_PUB)); + tx.vin.push_back(MineBlock(config, test_setup.m_node, SCRIPT_PUB)); tx.vin.back().scriptSig = scriptSig; tx.vout.emplace_back(1337 * SATOSHI, SCRIPT_PUB); if (NUM_BLOCKS - b >= COINBASE_MATURITY) { @@ -46,7 +46,8 @@ for (const auto &txr : txs) { TxValidationState vstate; - bool ret{::AcceptToMemoryPool(config, ::g_mempool, vstate, txr, + bool ret{::AcceptToMemoryPool(config, *test_setup.m_node.mempool, + vstate, txr, false /* bypass_limits */, /* nAbsurdFee */ Amount::zero())}; assert(ret); @@ -54,7 +55,7 @@ } while (state.KeepRunning()) { - PrepareBlock(config, g_testing_setup->m_node, SCRIPT_PUB); + PrepareBlock(config, test_setup.m_node, SCRIPT_PUB); } } diff --git a/src/bench/ccoins_caching.cpp b/src/bench/ccoins_caching.cpp --- a/src/bench/ccoins_caching.cpp +++ b/src/bench/ccoins_caching.cpp @@ -17,6 +17,9 @@ // every benchmark." // (https://github.com/bitcoin/bitcoin/issues/7883#issuecomment-224807484) static void CCoinsCaching(benchmark::State &state) { + const ECCVerifyHandle verify_handle; + ECC_Start(); + FillableSigningProvider keystore; CCoinsView coinsDummy; CCoinsViewCache coins(&coinsDummy); @@ -46,6 +49,7 @@ Amount value = coins.GetValueIn(t); assert(value == (50 + 21 + 22) * COIN); } + ECC_Stop(); } BENCHMARK(CCoinsCaching, 170 * 1000); diff --git a/src/bench/checkqueue.cpp b/src/bench/checkqueue.cpp --- a/src/bench/checkqueue.cpp +++ b/src/bench/checkqueue.cpp @@ -4,7 +4,9 @@ #include #include +#include #include +#include #include #include @@ -22,6 +24,9 @@ // checks all contain a prevector that is indirect 50% of the time and there is // a little bit of work done between calls to Add. static void CCheckQueueSpeedPrevectorJob(benchmark::State &state) { + const ECCVerifyHandle verify_handle; + ECC_Start(); + struct PrevectorJob { prevector p; PrevectorJob() {} @@ -54,5 +59,6 @@ } tg.interrupt_all(); tg.join_all(); + ECC_Stop(); } BENCHMARK(CCheckQueueSpeedPrevectorJob, 1400); diff --git a/src/bench/duplicate_inputs.cpp b/src/bench/duplicate_inputs.cpp --- a/src/bench/duplicate_inputs.cpp +++ b/src/bench/duplicate_inputs.cpp @@ -11,10 +11,13 @@ #include #include #include