Skip to content

Commit

Permalink
bench: Benchmark barycentric evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand committed Oct 1, 2024
1 parent d2c6fc7 commit ce592a9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions triton-vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ no_profile = [] # see `profiler.rs` for an explanation of this seemingly backwar
[lints]
workspace = true

[[bench]]
name = "barycentric_eval"
harness = false

[[bench]]
name = "bezout_coeffs"
harness = false
Expand Down
32 changes: 32 additions & 0 deletions triton-vm/benches/barycentric_eval.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use criterion::criterion_group;
use criterion::criterion_main;
use criterion::BatchSize;
use criterion::Criterion;
use itertools::Itertools;
use rand::prelude::StdRng;
use rand::Rng;
use rand_core::SeedableRng;
use triton_vm::fri::barycentric_evaluate;

criterion_main!(benches);
criterion_group!(
name = benches;
config = Criterion::default();
targets = barycentric_eval<11>,
barycentric_eval<13>,
barycentric_eval<15>,
barycentric_eval<17>,
barycentric_eval<19>,
barycentric_eval<21>,
);

fn barycentric_eval<const LOG2_N: usize>(c: &mut Criterion) {
let mut rng = StdRng::seed_from_u64(13902833756029401496);
c.bench_function(&format!("barycentric_evaluation_(1<<{LOG2_N})"), |b| {
b.iter_batched(
|| ((0..1 << LOG2_N).map(|_| rng.gen()).collect_vec(), rng.gen()),
|(codeword, indeterminate)| barycentric_evaluate(&codeword, indeterminate),
BatchSize::SmallInput,
)
});
}

0 comments on commit ce592a9

Please sign in to comment.