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.

43 lines
1.5 KiB

  1. // Copyright (c) 2023 Espresso Systems (espressosys.com)
  2. // This file is part of the HyperPlonk library.
  3. // You should have received a copy of the MIT License
  4. // along with the HyperPlonk library. If not, see <https://mit-license.org/>.
  5. #[macro_use]
  6. extern crate criterion;
  7. use arithmetic::fix_variables;
  8. use ark_bls12_381::Fr;
  9. use ark_ff::Field;
  10. use ark_poly::{DenseMultilinearExtension, MultilinearExtension};
  11. use ark_std::{ops::Range, test_rng};
  12. use criterion::{black_box, BenchmarkId, Criterion};
  13. const NUM_VARIABLES_RANGE: Range<usize> = 10..21;
  14. fn evaluation_op_bench<F: Field>(c: &mut Criterion) {
  15. let mut rng = test_rng();
  16. let mut group = c.benchmark_group("Evaluate");
  17. for nv in NUM_VARIABLES_RANGE {
  18. group.bench_with_input(BenchmarkId::new("evaluate native", nv), &nv, |b, &nv| {
  19. let poly = DenseMultilinearExtension::<F>::rand(nv, &mut rng);
  20. let point: Vec<_> = (0..nv).map(|_| F::rand(&mut rng)).collect();
  21. b.iter(|| black_box(poly.evaluate(&point).unwrap()))
  22. });
  23. group.bench_with_input(BenchmarkId::new("evaluate optimized", nv), &nv, |b, &nv| {
  24. let poly = DenseMultilinearExtension::<F>::rand(nv, &mut rng);
  25. let point: Vec<_> = (0..nv).map(|_| F::rand(&mut rng)).collect();
  26. b.iter(|| black_box(fix_variables(&poly, &point)))
  27. });
  28. }
  29. group.finish();
  30. }
  31. fn bench_bls_381(c: &mut Criterion) {
  32. evaluation_op_bench::<Fr>(c);
  33. }
  34. criterion_group!(benches, bench_bls_381);
  35. criterion_main!(benches);