40 static constexpr int MAX_CLUSTER_COUNT = 64;
42 static constexpr int NUM_TOP_CHAINS = 1000;
44 static constexpr int NUM_TX_PER_TOP_CHAIN = MAX_CLUSTER_COUNT;
46 static constexpr int NUM_DEPS_PER_BOTTOM_TX = 100;
48 static constexpr int32_t MAX_CLUSTER_SIZE = 100'000 * 100;
54 std::vector<TxGraph::Ref> top_refs;
56 std::vector<TxGraph::Ref> bottom_refs;
60 std::vector<size_t> top_components;
66 for (
int chain = 0; chain < NUM_TOP_CHAINS; ++chain) {
67 for (
int chaintx = 0; chaintx < NUM_TX_PER_TOP_CHAIN; ++chaintx) {
68 int64_t
fee = rng.randbits<27>() + 100;
70 top_refs.push_back(graph->AddTransaction(feerate));
73 graph->AddDependency(*(top_refs.rbegin()), *(top_refs.rbegin() + 1));
77 top_components.push_back(top_refs.size() - 1);
81 graph->GetBlockBuilder();
84 while (top_components.size() > 1) {
86 int64_t
fee = rng.randbits<27>() + 100;
88 auto bottom_tx = graph->AddTransaction(feerate);
90 int deps = std::min<int>(NUM_DEPS_PER_BOTTOM_TX, top_components.size());
91 for (
int dep = 0; dep < deps; ++dep) {
93 auto idx = rng.randrange(top_components.size());
95 graph->AddDependency(top_refs[top_components[idx]], bottom_tx);
100 if (idx != top_components.size() - 1) std::swap(top_components.back(), top_components[idx]);
102 top_components.pop_back();
105 bottom_refs.push_back(std::move(bottom_tx));
114 graph->GetBlockBuilder();
117 assert(!graph->IsOversized());
119 assert(graph->GetTransactionCount() >= (NUM_TOP_CHAINS * NUM_TX_PER_TOP_CHAIN * 99) / 100);
static void TxGraphTrim(benchmark::Bench &bench)
BENCHMARK(TxGraphTrim, benchmark::PriorityLevel::HIGH)
Main entry point to nanobench's benchmarking facility.
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Bench & epochs(size_t numEpochs) noexcept
Controls number of epochs, the number of measurements to perform.
Bench & epochIterations(uint64_t numIters) noexcept
Sets exactly the number of iterations for each epoch.
Tagged wrapper around FeeFrac to avoid unit confusion.
std::unique_ptr< TxGraph > MakeTxGraph(unsigned max_cluster_count, uint64_t max_cluster_size, uint64_t acceptable_iters) noexcept
Construct a new TxGraph with the specified limit on the number of transactions within a cluster,...
static constexpr uint64_t NUM_ACCEPTABLE_ITERS
The number used as acceptable_iters argument in these tests.