2#include <benchmark/benchmark.h>
19template <
typename Builder>
28 const size_t GATE_COUNT_BUFFER = 1000;
29 size_t current_gates =
builder.get_num_finalized_gates_inefficient(
false);
31 if (target_gate_count <= current_gates + GATE_COUNT_BUFFER) {
35 size_t passes = (target_gate_count - current_gates - GATE_COUNT_BUFFER) / 4;
37 for (
size_t i = 0; i < passes; ++i) {
44 size_t est_gate_count =
builder.get_num_finalized_gates_inefficient(
false);
46 target_gate_count - GATE_COUNT_BUFFER,
47 "Check that the finalized gate count won't exceed the desired gate count.");
61template <
typename Prover>
62Prover
get_prover(
void (*test_circuit_function)(
typename Prover::Flavor::CircuitBuilder&,
size_t),
63 size_t num_iterations)
65 using Flavor =
typename Prover::Flavor;
69 test_circuit_function(
builder, num_iterations);
75 return Prover(prover_instance, verification_key);
88template <
typename Prover>
90 benchmark::State& state,
91 void (*test_circuit_function)(
typename Prover::Flavor::CircuitBuilder&,
size_t),
92 size_t num_iterations)
96 for (
auto _ : state) {
99 Prover prover = get_prover<Prover>(test_circuit_function, num_iterations);
100 state.ResumeTiming();
103 auto proof = prover.construct_proof();
#define BB_ASSERT_LTE(left, right,...)
#define BB_BENCH_NAME(name)
ECCVMCircuitBuilder CircuitBuilder
static void add_default(Builder &builder)
Add default public inputs when they are not present.
void generate_basic_arithmetic_circuit_with_target_gates(Builder &builder, size_t target_gate_count)
Generate test circuit with basic arithmetic operations, targeting a specific gate count.
void generate_basic_arithmetic_circuit(Builder &builder, size_t log2_num_gates)
Generate test circuit with basic arithmetic operations, using log2 of gate count.
Prover get_prover(void(*test_circuit_function)(typename Prover::Flavor::CircuitBuilder &, size_t), size_t num_iterations)
void construct_proof_with_specified_num_iterations(benchmark::State &state, void(*test_circuit_function)(typename Prover::Flavor::CircuitBuilder &, size_t), size_t num_iterations)
Performs proof constuction for benchmarks based on a provided circuit function.
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static field random_element(numeric::RNG *engine=nullptr) noexcept
void throw_or_abort(std::string const &err)