Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bn254_decompress.bench.cpp
Go to the documentation of this file.
1#include <benchmark/benchmark.h>
2
7
8using namespace benchmark;
9using namespace bb;
10
11namespace {
12
16void bn254_point_decompression(benchmark::State& state)
17{
18 constexpr size_t NUM_POINTS = 1 << 17; // 131072 — typical circuit size
19
20 // Read compressed points from disk (32 bytes each, big-endian uint256_t)
21 auto compressed_buf = read_file(bb::srs::bb_crs_path() / "bn254_g1_compressed.dat", NUM_POINTS * sizeof(uint256_t));
23 for (size_t i = 0; i < NUM_POINTS; ++i) {
24 compressed[i] = from_buffer<uint256_t>(compressed_buf, i * sizeof(uint256_t));
25 }
26
27 for (auto _ : state) {
29 parallel_for([&](ThreadChunk chunk) {
30 for (auto i : chunk.range(NUM_POINTS)) {
31 points[i] = g1::affine_element::from_compressed(compressed[i]);
32 }
33 });
34 benchmark::DoNotOptimize(points);
35 }
36}
37BENCHMARK(bn254_point_decompression)->Unit(benchmark::kMillisecond);
38
39} // namespace
40
BENCHMARK_MAIN()
constexpr size_t NUM_POINTS
Definition fr.bench.cpp:127
std::filesystem::path bb_crs_path()
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
std::vector< uint8_t > read_file(const std::string &filename, size_t bytes=0)
Definition file_io.hpp:31
BENCHMARK(bench_commit_structured_random_poly< curve::BN254 >) -> Unit(benchmark::kMillisecond)
void parallel_for(size_t num_iterations, const std::function< void(size_t)> &func)
Definition thread.cpp:111
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13