From 08106404522b943063906c047535978ac54416c0 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Thu, 21 Mar 2024 14:12:18 +0000 Subject: [PATCH] chore: restrict CI to execution benches --- .github/workflows/bench.yml | 2 +- tooling/nargo_cli/Cargo.toml | 6 +++- .../benches/{criterion.rs => execution.rs} | 9 ++--- tooling/nargo_cli/benches/proof_generation.rs | 36 +++++++++++++++++++ 4 files changed, 44 insertions(+), 9 deletions(-) rename tooling/nargo_cli/benches/{criterion.rs => execution.rs} (81%) create mode 100644 tooling/nargo_cli/benches/proof_generation.rs diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 6d8314b8f93..466a3cd5558 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -28,4 +28,4 @@ jobs: with: branchName: "master" package: "nargo_cli" - benchName: "criterion" + benchName: "execution" diff --git a/tooling/nargo_cli/Cargo.toml b/tooling/nargo_cli/Cargo.toml index 1f73e0756f7..c1be18bae35 100644 --- a/tooling/nargo_cli/Cargo.toml +++ b/tooling/nargo_cli/Cargo.toml @@ -83,7 +83,11 @@ iai = "0.1.1" test-binary = "3.0.2" [[bench]] -name = "criterion" +name = "execution" +harness = false + +[[bench]] +name = "proof_generation" harness = false [features] diff --git a/tooling/nargo_cli/benches/criterion.rs b/tooling/nargo_cli/benches/execution.rs similarity index 81% rename from tooling/nargo_cli/benches/criterion.rs rename to tooling/nargo_cli/benches/execution.rs index 2090f593d95..3193e810664 100644 --- a/tooling/nargo_cli/benches/criterion.rs +++ b/tooling/nargo_cli/benches/execution.rs @@ -28,16 +28,11 @@ macro_rules! criterion_command { }; } criterion_command!(execution, "execute"); -criterion_command!(prove, "prove"); criterion_group! { name = execution_benches; config = Criterion::default().sample_size(20).measurement_time(Duration::from_secs(20)).with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); targets = criterion_selected_tests_execution } -criterion_group! { - name = prove_benches; - config = Criterion::default().sample_size(20).measurement_time(Duration::from_secs(20)).with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); - targets = criterion_selected_tests_prove -} -criterion_main!(execution_benches, prove_benches); + +criterion_main!(execution_benches); diff --git a/tooling/nargo_cli/benches/proof_generation.rs b/tooling/nargo_cli/benches/proof_generation.rs new file mode 100644 index 00000000000..7909d3e3767 --- /dev/null +++ b/tooling/nargo_cli/benches/proof_generation.rs @@ -0,0 +1,36 @@ +//! Select representative tests to bench with criterion +use assert_cmd::prelude::{CommandCargoExt, OutputAssertExt}; +use criterion::{criterion_group, criterion_main, Criterion}; + +use paste::paste; +use pprof::criterion::{Output, PProfProfiler}; +use std::{process::Command, time::Duration}; +include!("./utils.rs"); + +macro_rules! criterion_command { + ($command_name:tt, $command_string:expr) => { + paste! { + fn [](c: &mut Criterion) { + let test_program_dirs = get_selected_tests(); + for test_program_dir in test_program_dirs { + let mut cmd = Command::cargo_bin("nargo").unwrap(); + cmd.arg("--program-dir").arg(&test_program_dir); + cmd.arg($command_string); + cmd.arg("--force"); + + let benchmark_name = format!("{}_{}", test_program_dir.file_name().unwrap().to_str().unwrap(), $command_string); + c.bench_function(&benchmark_name, |b| { + b.iter(|| cmd.assert().success()) + }); + } + } + } + }; +} +criterion_command!(prove, "prove"); +criterion_group! { + name = prove_benches; + config = Criterion::default().sample_size(20).measurement_time(Duration::from_secs(20)).with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); + targets = criterion_selected_tests_execution +} +criterion_main!(prove_benches);