|
9 | 9 | #include <list>
|
10 | 10 | #include <vector>
|
11 | 11 |
|
12 |
| -static void AddTx(const CMutableTransaction& tx, const CAmount& nFee, CTxMemPool& pool) |
| 12 | +static void AddTx(const CTransactionRef& tx, const CAmount& nFee, CTxMemPool& pool) |
13 | 13 | {
|
14 | 14 | int64_t nTime = 0;
|
15 | 15 | unsigned int nHeight = 1;
|
16 | 16 | bool spendsCoinbase = false;
|
17 | 17 | unsigned int sigOpCost = 4;
|
18 | 18 | LockPoints lp;
|
19 |
| - pool.addUnchecked(tx.GetHash(), CTxMemPoolEntry( |
20 |
| - MakeTransactionRef(tx), nFee, nTime, nHeight, |
21 |
| - spendsCoinbase, sigOpCost, lp)); |
| 19 | + pool.addUnchecked(tx->GetHash(), CTxMemPoolEntry( |
| 20 | + tx, nFee, nTime, nHeight, |
| 21 | + spendsCoinbase, sigOpCost, lp)); |
22 | 22 | }
|
23 | 23 |
|
24 | 24 | // Right now this is only testing eviction performance in an extremely small
|
@@ -97,15 +97,23 @@ static void MempoolEviction(benchmark::State& state)
|
97 | 97 | tx7.vout[1].nValue = 10 * COIN;
|
98 | 98 |
|
99 | 99 | CTxMemPool pool;
|
| 100 | + // Create transaction references outside the "hot loop" |
| 101 | + const CTransactionRef tx1_r{MakeTransactionRef(tx1)}; |
| 102 | + const CTransactionRef tx2_r{MakeTransactionRef(tx2)}; |
| 103 | + const CTransactionRef tx3_r{MakeTransactionRef(tx3)}; |
| 104 | + const CTransactionRef tx4_r{MakeTransactionRef(tx4)}; |
| 105 | + const CTransactionRef tx5_r{MakeTransactionRef(tx5)}; |
| 106 | + const CTransactionRef tx6_r{MakeTransactionRef(tx6)}; |
| 107 | + const CTransactionRef tx7_r{MakeTransactionRef(tx7)}; |
100 | 108 |
|
101 | 109 | while (state.KeepRunning()) {
|
102 |
| - AddTx(tx1, 10000LL, pool); |
103 |
| - AddTx(tx2, 5000LL, pool); |
104 |
| - AddTx(tx3, 20000LL, pool); |
105 |
| - AddTx(tx4, 7000LL, pool); |
106 |
| - AddTx(tx5, 1000LL, pool); |
107 |
| - AddTx(tx6, 1100LL, pool); |
108 |
| - AddTx(tx7, 9000LL, pool); |
| 110 | + AddTx(tx1_r, 10000LL, pool); |
| 111 | + AddTx(tx2_r, 5000LL, pool); |
| 112 | + AddTx(tx3_r, 20000LL, pool); |
| 113 | + AddTx(tx4_r, 7000LL, pool); |
| 114 | + AddTx(tx5_r, 1000LL, pool); |
| 115 | + AddTx(tx6_r, 1100LL, pool); |
| 116 | + AddTx(tx7_r, 9000LL, pool); |
109 | 117 | pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4);
|
110 | 118 | pool.TrimToSize(GetVirtualTransactionSize(tx1));
|
111 | 119 | }
|
|
0 commit comments