Skip to content

Commit 30e240f

Browse files
committed
[bench] Benchmark CTxMemPool::check()
1 parent cb14071 commit 30e240f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/bench/mempool_stress.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <policy/policy.h>
77
#include <test/util/setup_common.h>
88
#include <txmempool.h>
9+
#include <validation.h>
910

1011
#include <vector>
1112

@@ -98,4 +99,20 @@ static void ComplexMemPool(benchmark::Bench& bench)
9899
});
99100
}
100101

102+
static void MempoolCheck(benchmark::Bench& bench)
103+
{
104+
FastRandomContext det_rand{true};
105+
const int childTxs = bench.complexityN() > 1 ? static_cast<int>(bench.complexityN()) : 2000;
106+
const std::vector<CTransactionRef> ordered_coins = CreateOrderedCoins(det_rand, childTxs, /* min_ancestors */ 5);
107+
const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(CBaseChainParams::MAIN, {"-checkmempool=1"});
108+
CTxMemPool pool;
109+
LOCK2(cs_main, pool.cs);
110+
for (auto& tx : ordered_coins) AddTx(tx, pool);
111+
112+
bench.run([&]() NO_THREAD_SAFETY_ANALYSIS {
113+
pool.check(testing_setup.get()->m_node.chainman->ActiveChainstate());
114+
});
115+
}
116+
101117
BENCHMARK(ComplexMemPool);
118+
BENCHMARK(MempoolCheck);

0 commit comments

Comments
 (0)