You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.2 KiB

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