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.

27 lines
780 B

  1. use criterion::{criterion_group, criterion_main, Criterion};
  2. use num_bigint::BigInt;
  3. use mimc_rs::Mimc7;
  4. fn criterion_benchmark(c: &mut Criterion) {
  5. let b1: BigInt = BigInt::parse_bytes(
  6. b"12242166908188651009877250812424843524687801523336557272219921456462821518061",
  7. 10,
  8. )
  9. .unwrap();
  10. let b2: BigInt = BigInt::parse_bytes(
  11. b"12242166908188651009877250812424843524687801523336557272219921456462821518061",
  12. 10,
  13. )
  14. .unwrap();
  15. let mut big_arr: Vec<BigInt> = Vec::new();
  16. big_arr.push(b1.clone());
  17. big_arr.push(b2.clone());
  18. let mimc7 = Mimc7::new();
  19. c.bench_function("hash", |b| b.iter(|| mimc7.hash(big_arr.clone()).unwrap()));
  20. }
  21. criterion_group!(benches, criterion_benchmark);
  22. criterion_main!(benches);