diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp index d1d468b0f8f..a47d1cc1460 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp @@ -12,23 +12,59 @@ auto& engine = numeric::random::get_debug_engine(); namespace proof_system::plonk { -template void execute_widget(::benchmark::State& state) +struct BasicPlonkKeyAndTranscript { + std::shared_ptr key; + transcript::StandardTranscript transcript; +}; + +BasicPlonkKeyAndTranscript get_plonk_key_and_transcript() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); auto inner_composer = plonk::UltraComposer(); auto builder = typename plonk::UltraComposer::CircuitBuilder(); bench_utils::generate_basic_arithmetic_circuit(builder, 80); - auto inner_prover = inner_composer.create_prover(builder); - auto inner_proof = inner_prover.construct_proof(); + UltraProver inner_prover = inner_composer.create_prover(builder); + inner_prover.construct_proof(); + return { inner_composer.circuit_proving_key, inner_prover.transcript }; +} + +template void execute_widget(::benchmark::State& state) +{ + BasicPlonkKeyAndTranscript data = get_plonk_key_and_transcript(); + Widget widget(data.key); for (auto _ : state) { - Widget widget(inner_composer.circuit_proving_key.get()); - widget.compute_quotient_contribution(barretenberg::fr::random_element(), inner_prover.transcript); + widget.compute_quotient_contribution(barretenberg::fr::random_element(), data.transcript); } } +void plookup_auxiliary_kernel(::benchmark::State& state) noexcept +{ + BasicPlonkKeyAndTranscript data = get_plonk_key_and_transcript(); + + using FFTGetter = ProverPlookupAuxiliaryWidget::FFTGetter; + using FFTKernel = ProverPlookupAuxiliaryWidget::FFTKernel; + + auto polynomials = FFTGetter::get_polynomials(data.key.get(), FFTKernel::get_required_polynomial_ids()); + auto challenges = FFTGetter::get_challenges( + data.transcript, barretenberg::fr::random_element(), FFTKernel::quotient_required_challenges); + + for (auto _ : state) { + // NOTE: this simply calls the following 3 functions it does NOT try to replicate ProverPlookupAuxiliaryWidget + // logic exactly + widget::containers::coefficient_array linear_terms; + FFTKernel::compute_linear_terms(polynomials, challenges, linear_terms, 0); + barretenberg::fr sum_of_linear_terms = FFTKernel::sum_linear_terms(polynomials, challenges, linear_terms, 0); + FFTKernel::compute_non_linear_terms(polynomials, challenges, sum_of_linear_terms, 0); + } +} +BENCHMARK(plookup_auxiliary_kernel); void plookup_auxiliary_widget(::benchmark::State& state) noexcept { - execute_widget>(state); + BasicPlonkKeyAndTranscript data = get_plonk_key_and_transcript(); + ProverPlookupAuxiliaryWidget widget(data.key.get()); + for (auto _ : state) { + widget.compute_quotient_contribution(barretenberg::fr::random_element(), data.transcript); + } } BENCHMARK(plookup_auxiliary_widget);