2#include <benchmark/benchmark.h>
27 size_t target_gate_count = (1UL << log2_num_gates);
28 const size_t GATE_COUNT_BUFFER = 1000;
29 size_t passes = (target_gate_count -
builder.get_estimated_num_finalized_gates() - GATE_COUNT_BUFFER) / 4;
30 if (
static_cast<int>(passes) <= 0) {
34 for (
size_t i = 0; i < passes; ++i) {
41 size_t est_gate_count =
builder.get_estimated_num_finalized_gates();
43 (1UL << log2_num_gates) - GATE_COUNT_BUFFER,
44 "Check that the finalized gate count won't exceed the desired gate count.");
47template <
typename Prover>
48Prover
get_prover(
void (*test_circuit_function)(
typename Prover::Flavor::CircuitBuilder&,
size_t),
49 size_t num_iterations)
51 using Flavor =
typename Prover::Flavor;
55 test_circuit_function(
builder, num_iterations);
61 return Prover(proving_key, verification_key);
74template <
typename Prover>
76 benchmark::State& state,
77 void (*test_circuit_function)(
typename Prover::Flavor::CircuitBuilder&,
size_t),
78 size_t num_iterations)
82 for (
auto _ : state) {
85 Prover prover = get_prover<Prover>(test_circuit_function, num_iterations);
89 auto proof = prover.construct_proof();
#define BB_ASSERT_LTE(left, right,...)
MegaCircuitBuilder CircuitBuilder
void generate_basic_arithmetic_circuit(Builder &builder, size_t log2_num_gates)
Generate test circuit with basic arithmetic operations.
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
#define PROFILE_THIS_NAME(name)
static field random_element(numeric::RNG *engine=nullptr) noexcept
static void add_default_to_public_inputs(Builder &builder)
Adds default public inputs to the builder.
void throw_or_abort(std::string const &err)