arnaucube
arnaucube/testudoPublic Self-hosted repository
testudo/benches/commitments.rs
benches/commitments.rsRaw
 1extern crate byteorder;
 2extern crate core;
 3extern crate criterion;
 4extern crate curve25519_dalek;
 5extern crate digest;
 6extern crate libspartan;
 7extern crate merlin;
 8extern crate rand;
 9extern crate sha3;
10
11use libspartan::commitments::{Commitments, MultiCommitGens};
12use libspartan::math::Math;
13use libspartan::scalar::Scalar;
14use rand::rngs::OsRng;
15
16use criterion::*;
17
18fn commitment_benchmark(c: &mut Criterion) {
19  let mut rng = OsRng;
20  for &s in [20].iter() {
21    let plot_config = PlotConfiguration::default().summary_scale(AxisScale::Logarithmic);
22    let mut group = c.benchmark_group("commitment_bools");
23    group.plot_config(plot_config);
24
25    let n = (s as usize).pow2();
26    let gens = MultiCommitGens::new(n, b"test-m");
27    let blind = Scalar::random(&mut rng);
28    let vec: Vec<bool> = vec![true; n];
29    let name = format!("commitment_bools_{}", n);
30    group.bench_function(&name, move |b| {
31      b.iter(|| vec.commit(black_box(&blind), black_box(&gens)));
32    });
33    group.finish();
34  }
35}
36
37fn set_duration() -> Criterion {
38  Criterion::default().sample_size(10)
39  // .measurement_time(Duration::new(0, 50000000))
40}
41
42criterion_group! {
43name = benches_commitment;
44config = set_duration();
45targets = commitment_benchmark
46}
47
48criterion_main!(benches_commitment);