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.

30 lines
872 B

  1. use criterion::{black_box, criterion_group, criterion_main, Criterion};
  2. extern crate rand;
  3. #[macro_use]
  4. extern crate ff;
  5. use ff::*;
  6. use poseidon_rs::Poseidon;
  7. fn criterion_benchmark(c: &mut Criterion) {
  8. let b1: poseidon_rs::Fr = poseidon_rs::Fr::from_str(
  9. "12242166908188651009877250812424843524687801523336557272219921456462821518061",
  10. )
  11. .unwrap();
  12. let b2: poseidon_rs::Fr = poseidon_rs::Fr::from_str(
  13. "12242166908188651009877250812424843524687801523336557272219921456462821518061",
  14. )
  15. .unwrap();
  16. let mut big_arr: Vec<poseidon_rs::Fr> = Vec::new();
  17. big_arr.push(b1.clone());
  18. big_arr.push(b2.clone());
  19. let poseidon = Poseidon::new();
  20. c.bench_function("hash", |b| {
  21. b.iter(|| poseidon.hash(big_arr.clone()).unwrap())
  22. });
  23. }
  24. criterion_group!(benches, criterion_benchmark);
  25. criterion_main!(benches);