diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 556838ad..c068e531 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,3 +90,12 @@ jobs: run: | cargo bench --bench riscv_machine + bench-nova-public-params: + runs-on: ubuntu-latest + if: contains(github.event.pull_request.labels.*.name, 'benchmark') + steps: + - uses: actions/checkout@v4 + - name: Run benchmarks + run: | + cargo bench --bench nova_public_parameter_generation + diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 99f52f5e..7d332e28 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -12,7 +12,11 @@ categories = { workspace = true } [dependencies] serde.workspace = true -nexus-core = { path = "../core", features = ["prover_nova", "prover_jolt", "prover_hypernova"] } +nexus-core = { path = "../core", features = [ + "prover_nova", + "prover_jolt", + "prover_hypernova", +] } nexus-macro = { path = "../macro" } postcard = { version = "1.0.8", features = ["alloc"] } uuid = { version = "1.9.1", features = ["v4", "fast-rng"] } @@ -20,6 +24,13 @@ thiserror = "1.0.61" [dev-dependencies] nexus-profiler = { path = "../macro/profiler" } +criterion = "0.5.1" +iai-callgrind = "0.12.2" [lib] doctest = false + +[[bench]] +name = "nova_public_parameter_generation" +harness = false + diff --git a/sdk/benches/nova_public_parameter_generation.rs b/sdk/benches/nova_public_parameter_generation.rs new file mode 100644 index 00000000..88ca1595 --- /dev/null +++ b/sdk/benches/nova_public_parameter_generation.rs @@ -0,0 +1,21 @@ +use criterion::{criterion_group, criterion_main, Criterion}; +use nexus_sdk::nova; +use nexus_sdk::Parameters; + +fn nova_public_parameter_generation() { + nova::seq::PP::generate_for_testing().expect("Failed to generate Nova public parameters"); +} + +#[allow(clippy::redundant_closure)] +fn bench_nova_public_parameter(c: &mut Criterion) { + c.bench_function("nova_public_parameter", |b| { + b.iter(|| nova_public_parameter_generation()) + }); +} + +criterion_group!( + name = benches; + config = Criterion::default().significance_level(0.1).sample_size(10); + targets = bench_nova_public_parameter); + +criterion_main!(benches);