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.

47 lines
1.2 KiB

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