13#include <benchmark/benchmark.h>
18using namespace benchmark;
29template <
typename TreeType>
void perform_batch_insert(
TreeType& tree,
const std::vector<fr>& values)
35 signal.wait_for_level(0);
41 auto completion = [&]() ->
void { signal.signal_level(0); };
43 signal.wait_for_level(0);
46template <
typename TreeType>
void append_only_tree_bench(State& state)
noexcept
48 const size_t batch_size = size_t(state.range(0));
53 std::filesystem::create_directories(directory);
54 uint32_t num_threads = 16;
61 for (
auto _ : state) {
63 std::vector<fr> values(batch_size);
64 for (
size_t i = 0; i < batch_size; ++i) {
68 perform_batch_insert(tree, values);
71 std::filesystem::remove_all(directory);
73BENCHMARK(append_only_tree_bench<Poseidon2>)
74 ->Unit(benchmark::kMillisecond)
78BENCHMARK(append_only_tree_bench<Poseidon2>)
79 ->Unit(benchmark::kMillisecond)
Native Poseidon2 hash function implementation.
Implements a simple append-only merkle tree All methods are asynchronous unless specified as otherwis...
void commit(const CommitCallback &on_completion)
Commit the tree to the backing store.
virtual void add_values(const std::vector< fr > &values, const AppendCompletionCallback &on_completion)
Adds the given set of values to the end of the tree.
Serves as a key-value node store for merkle trees. Caches all changes in memory before persisting the...
std::shared_ptr< LMDBTreeStore > SharedPtr
Used in parallel insertions in the the IndexedTree. Workers signal to other following workes as they ...
ContentAddressedAppendOnlyTree< Store, Poseidon2HashPolicy > TreeType
void commit_tree(TreeType &tree, bool expected_success=true)
const size_t MAX_BATCH_SIZE
std::string random_temp_directory()
std::string random_string()
field< Bn254FrParams > fr
BENCHMARK(bench_commit_structured_random_poly< curve::BN254 >) -> Unit(benchmark::kMillisecond)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept