| 121 | } |
| 122 | |
| 123 | static void ComplexMemPool(benchmark::Bench& bench) |
| 124 | { |
| 125 | FastRandomContext det_rand{true}; |
| 126 | int childTxs = 50; |
| 127 | if (bench.complexityN() > 1) { |
| 128 | childTxs = static_cast<int>(bench.complexityN()); |
| 129 | } |
| 130 | const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN); |
| 131 | CTxMemPool& pool = *testing_setup.get()->m_node.mempool; |
| 132 | |
| 133 | std::vector<CTransactionRef> tx_remove_for_block; |
| 134 | std::vector<Txid> hashes_remove_for_block; |
| 135 | |
| 136 | LOCK2(cs_main, pool.cs); |
| 137 | |
| 138 | for (int i=0; i<1000; i++) { |
| 139 | std::vector<CTransactionRef> transactions = CreateCoinCluster(det_rand, childTxs, /*min_ancestors=*/1); |
| 140 | |
| 141 | // Add all transactions to the mempool. |
| 142 | // Also store the first 10 transactions from each cluster as the |
| 143 | // transactions we'll "mine" in the benchmark. |
| 144 | int tx_count = 0; |
| 145 | for (auto& tx : transactions) { |
| 146 | if (tx_count < 10) { |
| 147 | tx_remove_for_block.push_back(tx); |
| 148 | ++tx_count; |
| 149 | hashes_remove_for_block.emplace_back(tx->GetHash()); |
| 150 | } |
| 151 | AddTx(tx, pool, det_rand); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | // Since the benchmark will be run repeatedly, we have to leave the mempool |
| 156 | // in the same state at the end of the function, so we benchmark both |
| 157 | // mining a block and reorging the block's contents back into the mempool. |
| 158 | bench.run([&]() NO_THREAD_SAFETY_ANALYSIS { |
| 159 | pool.removeForBlock(tx_remove_for_block, /*nBlockHeight=*/100); |
| 160 | for (auto& tx: tx_remove_for_block) { |
| 161 | AddTx(tx, pool, det_rand); |
| 162 | } |
| 163 | pool.UpdateTransactionsFromBlock(hashes_remove_for_block); |
| 164 | }); |
| 165 | } |
| 166 | |
| 167 | static void MemPoolAncestorsDescendants(benchmark::Bench& bench) |
| 168 | { |
nothing calls this directly
no test coverage detected