Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
written_slots_tree.bench.cpp
Go to the documentation of this file.
2
3#include <benchmark/benchmark.h>
4#include <chrono>
5#include <stack>
6
9
10using namespace benchmark;
11using namespace bb::avm2;
13
14namespace bb::avm2::simulation {
15
16static void BM_WrittenSlotsTreeStack(benchmark::State& state)
17{
18 const size_t stack_size = static_cast<size_t>(state.range(0));
19
20 auto base_tree = build_public_data_slots_tree();
22 for (size_t i = 0; i < MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX; ++i) {
23 leaves.push_back(WrittenPublicDataSlotLeafValue(FF::random_element()));
24 }
25 base_tree.insert_indexed_leaves(leaves);
26
27 for (auto _ : state) {
29 tree_stack.push(base_tree);
30
31 for (size_t i = 0; i < stack_size; ++i) {
32 tree_stack.push(tree_stack.top());
33 }
34
35 for (size_t i = 0; i < stack_size; ++i) {
36 WrittenPublicDataSlotsTree current_tree = std::move(tree_stack.top());
37 tree_stack.pop();
38 tree_stack.top() = std::move(current_tree);
39 }
40
41 benchmark::DoNotOptimize(tree_stack);
42 benchmark::ClobberMemory();
43
44 if (tree_stack.size() != 1) {
45 state.SkipWithError("Stack size is not 1 after unwind");
46 }
47 }
48}
49
50BENCHMARK(BM_WrittenSlotsTreeStack)->Arg(1000)->Arg(3000)->Arg(6000)->Arg(9000)->Unit(benchmark::kMicrosecond);
51
52} // namespace bb::avm2::simulation
53
#define MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX
WrittenPublicDataSlotsTree build_public_data_slots_tree()
BENCHMARK(extend_2_to_11)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
BENCHMARK_MAIN()