7 #include <test/util/setup_common.h> 19 pool.addUnchecked(
CTxMemPoolEntry(tx, 1000, nTime, nHeight, spendsCoinbase, sigOpCost, lp));
37 std::vector<Available> available_coins;
38 std::vector<CTransactionRef> ordered_coins;
40 size_t tx_counter = 1;
41 for (
auto x = 0; x < 100; ++x) {
45 tx.
vin[0].scriptWitness.stack.push_back(
CScriptNum(x).getvch());
46 tx.
vout.resize(det_rand.randrange(10)+2);
47 for (
auto& out : tx.
vout) {
49 out.nValue = 10 *
COIN;
52 available_coins.emplace_back(ordered_coins.back(), tx_counter++);
54 for (
auto x = 0; x < childTxs && !available_coins.empty(); ++x) {
56 size_t n_ancestors = det_rand.randrange(10)+1;
57 for (
size_t ancestor = 0; ancestor < n_ancestors && !available_coins.empty(); ++ancestor){
58 size_t idx = det_rand.randrange(available_coins.size());
62 size_t n_to_take = det_rand.randrange(2) == 0 ? 1 : 1+det_rand.randrange(coin.
ref->vout.size() - coin.
vin_left);
63 for (
size_t i = 0; i < n_to_take; ++i) {
64 tx.
vin.emplace_back();
70 coin = available_coins.back();
71 available_coins.pop_back();
73 tx.
vout.resize(det_rand.randrange(10)+2);
74 for (
auto& out : tx.
vout) {
76 out.nValue = 10 *
COIN;
80 available_coins.emplace_back(ordered_coins.back(), tx_counter++);
82 TestingSetup test_setup;
86 for (
auto& tx : ordered_coins) {
std::shared_ptr< const CTransaction > CTransactionRef
#define NO_THREAD_SAFETY_ANALYSIS
size_t DynamicMemoryUsage() const
static const CAmount COIN
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
Available(CTransactionRef &ref, size_t tx_count)
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
BENCHMARK(ComplexMemPool)
Bench & complexityN(T b) noexcept
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
std::vector< unsigned char > getvch() const
An outpoint - a combination of a transaction hash and an index n into its vout.
std::vector< CTxOut > vout
static CTransactionRef MakeTransactionRef(Tx &&txIn)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Serialized script, used inside transaction inputs and outputs.
static void ComplexMemPool(benchmark::Bench &bench)
A mutable version of CTransaction.
void TrimToSize(size_t sizelimit, std::vector< COutPoint > *pvNoSpendsRemaining=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs)
Remove transactions from the mempool until its dynamic size is <= sizelimit.
Main entry point to nanobench's benchmarking facility.
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it...
static void AddTx(const CTransactionRef &tx, CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main