MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / MemPoolAddTransactions

Function MemPoolAddTransactions

src/bench/mempool_stress.cpp:96–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96static void MemPoolAddTransactions(benchmark::Bench& bench)
97{
98 FastRandomContext det_rand{true};
99 int childTxs = 50;
100 if (bench.complexityN() > 1) {
101 childTxs = static_cast<int>(bench.complexityN());
102 }
103 const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN);
104 CTxMemPool& pool = *testing_setup.get()->m_node.mempool;
105
106 std::vector<CTransactionRef> transactions;
107 // Create 1000 clusters of 100 transactions each
108 for (int i=0; i<100; i++) {
109 auto new_txs = CreateCoinCluster(det_rand, childTxs, /*min_ancestors=*/ 1);
110 transactions.insert(transactions.end(), new_txs.begin(), new_txs.end());
111 }
112
113 LOCK2(cs_main, pool.cs);
114
115 bench.run([&]() NO_THREAD_SAFETY_ANALYSIS {
116 for (auto& tx : transactions) {
117 AddTx(tx, pool, det_rand);
118 }
119 pool.TrimToSize(0, nullptr);
120 });
121}
122
123static void ComplexMemPool(benchmark::Bench& bench)
124{

Callers

nothing calls this directly

Calls 9

CreateCoinClusterFunction · 0.85
complexityNMethod · 0.80
TrimToSizeMethod · 0.80
AddTxFunction · 0.70
getMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected