45 static constexpr int MAX_CLUSTER_COUNT = 64;
47 static constexpr int NUM_TOP_CHAINS = 1000;
49 static constexpr int NUM_TX_PER_TOP_CHAIN = MAX_CLUSTER_COUNT;
51 static constexpr int NUM_DEPS_PER_BOTTOM_TX = 100;
53 static constexpr int32_t MAX_CLUSTER_SIZE = 100'000 * 100;
56 static constexpr uint64_t NUM_ACCEPTABLE_ITERS = 100'000'000;
59 std::vector<TxGraph::Ref> top_refs;
61 std::vector<TxGraph::Ref> bottom_refs;
65 std::vector<size_t> top_components;
68 auto graph =
MakeTxGraph(MAX_CLUSTER_COUNT, MAX_CLUSTER_SIZE, NUM_ACCEPTABLE_ITERS, PointerComparator);
71 for (
int chain = 0; chain < NUM_TOP_CHAINS; ++chain) {
72 for (
int chaintx = 0; chaintx < NUM_TX_PER_TOP_CHAIN; ++chaintx) {
73 int64_t
fee = rng.randbits<27>() + 100;
75 graph->AddTransaction(top_refs.emplace_back(), feerate);
78 graph->AddDependency(*(top_refs.rbegin()), *(top_refs.rbegin() + 1));
82 top_components.push_back(top_refs.size() - 1);
86 graph->GetBlockBuilder();
89 while (top_components.size() > 1) {
91 int64_t
fee = rng.randbits<27>() + 100;
94 graph->AddTransaction(bottom_tx, feerate);
96 int deps = std::min<int>(NUM_DEPS_PER_BOTTOM_TX, top_components.size());
97 for (
int dep = 0; dep < deps; ++dep) {
99 auto idx = rng.randrange(top_components.size());
101 graph->AddDependency(top_refs[top_components[idx]], bottom_tx);
104 if (dep < deps - 1) {
106 if (idx != top_components.size() - 1) std::swap(top_components.back(), top_components[idx]);
108 top_components.pop_back();
111 bottom_refs.push_back(std::move(bottom_tx));
120 graph->GetBlockBuilder();
static void TxGraphTrim(benchmark::Bench &bench)
@ 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_iters, 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,...