52 static constexpr int MAX_CLUSTER_COUNT = 64;
54 static constexpr int NUM_TOP_CHAINS = 1000;
56 static constexpr int NUM_TX_PER_TOP_CHAIN = MAX_CLUSTER_COUNT;
58 static constexpr int NUM_DEPS_PER_BOTTOM_TX = 100;
60 static constexpr int32_t MAX_CLUSTER_SIZE = 100'000 * 100;
63 static constexpr uint64_t HIGH_ACCEPTABLE_COST = 100'000'000;
66 std::vector<TxGraph::Ref> top_refs;
68 std::vector<TxGraph::Ref> bottom_refs;
72 std::vector<size_t> top_components;
75 auto graph =
MakeTxGraph(MAX_CLUSTER_COUNT, MAX_CLUSTER_SIZE, HIGH_ACCEPTABLE_COST, PointerComparator);
78 for (
int chain = 0; chain < NUM_TOP_CHAINS; ++chain) {
79 for (
int chaintx = 0; chaintx < NUM_TX_PER_TOP_CHAIN; ++chaintx) {
82 graph->AddTransaction(top_refs.emplace_back(), feerate);
85 graph->AddDependency(*(top_refs.rbegin()), *(top_refs.rbegin() + 1));
89 top_components.push_back(top_refs.size() - 1);
93 graph->GetBlockBuilder();
96 while (top_components.size() > 1) {
101 graph->AddTransaction(bottom_tx, feerate);
103 int deps = std::min<int>(NUM_DEPS_PER_BOTTOM_TX, top_components.size());
104 for (
int dep = 0; dep < deps; ++dep) {
108 graph->AddDependency(top_refs[top_components[idx]], bottom_tx);
111 if (dep < deps - 1) {
113 if (idx != top_components.size() - 1) std::swap(top_components.back(), top_components[idx]);
115 top_components.pop_back();
118 bottom_refs.push_back(std::move(bottom_tx));
127 graph->GetBlockBuilder();
static void TxGraphTrim(benchmark::Bench &bench)
I randrange(I range) noexcept
Generate a random integer in the range [0..range), with range > 0.
uint64_t randbits(int bits) noexcept
Generate a random (bits)-bit integer.
@ TOP
Refers to staging if it exists, main otherwise.
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_cost, const std::function< std::strong_ordering(const TxGraph::Ref &, const TxGraph::Ref &)> &fallback_order) noexcept
Construct a new TxGraph with the specified limit on the number of transactions within a cluster,...