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.

37 lines
1.3 KiB

  1. #[macro_use]
  2. extern crate criterion;
  3. use arithmetic::fix_variables;
  4. use ark_bls12_381::Fr;
  5. use ark_ff::Field;
  6. use ark_poly::{DenseMultilinearExtension, MultilinearExtension};
  7. use ark_std::{ops::Range, test_rng};
  8. use criterion::{black_box, BenchmarkId, Criterion};
  9. const NUM_VARIABLES_RANGE: Range<usize> = 10..21;
  10. fn evaluation_op_bench<F: Field>(c: &mut Criterion) {
  11. let mut rng = test_rng();
  12. let mut group = c.benchmark_group("Evaluate");
  13. for nv in NUM_VARIABLES_RANGE {
  14. group.bench_with_input(BenchmarkId::new("evaluate native", nv), &nv, |b, &nv| {
  15. let poly = DenseMultilinearExtension::<F>::rand(nv, &mut rng);
  16. let point: Vec<_> = (0..nv).map(|_| F::rand(&mut rng)).collect();
  17. b.iter(|| black_box(poly.evaluate(&point).unwrap()))
  18. });
  19. group.bench_with_input(BenchmarkId::new("evaluate optimized", nv), &nv, |b, &nv| {
  20. let poly = DenseMultilinearExtension::<F>::rand(nv, &mut rng);
  21. let point: Vec<_> = (0..nv).map(|_| F::rand(&mut rng)).collect();
  22. b.iter(|| black_box(fix_variables(&poly, &point)))
  23. });
  24. }
  25. group.finish();
  26. }
  27. fn bench_bls_381(c: &mut Criterion) {
  28. evaluation_op_bench::<Fr>(c);
  29. }
  30. criterion_group!(benches, bench_bls_381);
  31. criterion_main!(benches);