Changeset View
Changeset View
Standalone View
Standalone View
src/bench/mempool_eviction.cpp
Show All 15 Lines | static void AddTx(const CTransactionRef &tx, const Amount &nFee, | ||||
LockPoints lp; | LockPoints lp; | ||||
pool.addUnchecked(CTxMemPoolEntry(tx, nFee, nTime, nHeight, spendsCoinbase, | pool.addUnchecked(CTxMemPoolEntry(tx, nFee, nTime, nHeight, spendsCoinbase, | ||||
nSigOpCount, lp)); | nSigOpCount, lp)); | ||||
} | } | ||||
// Right now this is only testing eviction performance in an extremely small | // Right now this is only testing eviction performance in an extremely small | ||||
// mempool. Code needs to be written to generate a much wider variety of | // mempool. Code needs to be written to generate a much wider variety of | ||||
// unique transactions for a more meaningful performance measurement. | // unique transactions for a more meaningful performance measurement. | ||||
static void MempoolEviction(benchmark::State &state) { | static void MempoolEviction(benchmark::Bench &bench) { | ||||
TestingSetup test_setup{ | TestingSetup test_setup{ | ||||
CBaseChainParams::REGTEST, | CBaseChainParams::REGTEST, | ||||
/* extra_args */ | /* extra_args */ | ||||
{ | { | ||||
"-nodebuglogfile", | "-nodebuglogfile", | ||||
"-nodebug", | "-nodebug", | ||||
}, | }, | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | static void MempoolEviction(benchmark::Bench &bench) { | ||||
const CTransactionRef tx1_r{MakeTransactionRef(tx1)}; | const CTransactionRef tx1_r{MakeTransactionRef(tx1)}; | ||||
const CTransactionRef tx2_r{MakeTransactionRef(tx2)}; | const CTransactionRef tx2_r{MakeTransactionRef(tx2)}; | ||||
const CTransactionRef tx3_r{MakeTransactionRef(tx3)}; | const CTransactionRef tx3_r{MakeTransactionRef(tx3)}; | ||||
const CTransactionRef tx4_r{MakeTransactionRef(tx4)}; | const CTransactionRef tx4_r{MakeTransactionRef(tx4)}; | ||||
const CTransactionRef tx5_r{MakeTransactionRef(tx5)}; | const CTransactionRef tx5_r{MakeTransactionRef(tx5)}; | ||||
const CTransactionRef tx6_r{MakeTransactionRef(tx6)}; | const CTransactionRef tx6_r{MakeTransactionRef(tx6)}; | ||||
const CTransactionRef tx7_r{MakeTransactionRef(tx7)}; | const CTransactionRef tx7_r{MakeTransactionRef(tx7)}; | ||||
while (state.KeepRunning()) { | bench.run([&]() NO_THREAD_SAFETY_ANALYSIS { | ||||
AddTx(tx1_r, 10000 * SATOSHI, pool); | AddTx(tx1_r, 10000 * SATOSHI, pool); | ||||
AddTx(tx2_r, 5000 * SATOSHI, pool); | AddTx(tx2_r, 5000 * SATOSHI, pool); | ||||
AddTx(tx3_r, 20000 * SATOSHI, pool); | AddTx(tx3_r, 20000 * SATOSHI, pool); | ||||
AddTx(tx4_r, 7000 * SATOSHI, pool); | AddTx(tx4_r, 7000 * SATOSHI, pool); | ||||
AddTx(tx5_r, 1000 * SATOSHI, pool); | AddTx(tx5_r, 1000 * SATOSHI, pool); | ||||
AddTx(tx6_r, 1100 * SATOSHI, pool); | AddTx(tx6_r, 1100 * SATOSHI, pool); | ||||
AddTx(tx7_r, 9000 * SATOSHI, pool); | AddTx(tx7_r, 9000 * SATOSHI, pool); | ||||
pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4); | pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4); | ||||
pool.TrimToSize(GetSerializeSize(*tx1_r, PROTOCOL_VERSION)); | pool.TrimToSize(GetSerializeSize(*tx1_r, PROTOCOL_VERSION)); | ||||
} | }); | ||||
} | } | ||||
BENCHMARK(MempoolEviction, 41000); | BENCHMARK(MempoolEviction); |