aboutsummaryrefslogtreecommitdiff
path: root/src/bench/mempool_stress.cpp
diff options
context:
space:
mode:
authorglozow <gloriajzhao@gmail.com>2021-09-30 09:31:18 +0100
committerglozow <gloriajzhao@gmail.com>2021-10-04 15:00:28 +0100
commit30e240f65e69c6dffcd033afc63895345bd51f53 (patch)
treeabbf90c2cf8baeefb7d85b7cad08e346df127ff9 /src/bench/mempool_stress.cpp
parentcb1407196fba648aa75504e3ab3d46aa0181563a (diff)
downloadbitcoin-30e240f65e69c6dffcd033afc63895345bd51f53.tar.xz
[bench] Benchmark CTxMemPool::check()
Diffstat (limited to 'src/bench/mempool_stress.cpp')
-rw-r--r--src/bench/mempool_stress.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/bench/mempool_stress.cpp b/src/bench/mempool_stress.cpp
index 21d7407fca..16c57881d4 100644
--- a/src/bench/mempool_stress.cpp
+++ b/src/bench/mempool_stress.cpp
@@ -6,6 +6,7 @@
#include <policy/policy.h>
#include <test/util/setup_common.h>
#include <txmempool.h>
+#include <validation.h>
#include <vector>
@@ -98,4 +99,20 @@ static void ComplexMemPool(benchmark::Bench& bench)
});
}
+static void MempoolCheck(benchmark::Bench& bench)
+{
+ FastRandomContext det_rand{true};
+ const int childTxs = bench.complexityN() > 1 ? static_cast<int>(bench.complexityN()) : 2000;
+ const std::vector<CTransactionRef> ordered_coins = CreateOrderedCoins(det_rand, childTxs, /* min_ancestors */ 5);
+ const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(CBaseChainParams::MAIN, {"-checkmempool=1"});
+ CTxMemPool pool;
+ LOCK2(cs_main, pool.cs);
+ for (auto& tx : ordered_coins) AddTx(tx, pool);
+
+ bench.run([&]() NO_THREAD_SAFETY_ANALYSIS {
+ pool.check(testing_setup.get()->m_node.chainman->ActiveChainstate());
+ });
+}
+
BENCHMARK(ComplexMemPool);
+BENCHMARK(MempoolCheck);