use std::any::type_name; use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use p3_baby_bear::{BabyBear, MdsMatrixBabyBear}; use p3_field::{AbstractField, Field}; use p3_goldilocks::{Goldilocks, MdsMatrixGoldilocks}; use p3_mds::coset_mds::CosetMds; use p3_mds::integrated_coset_mds::IntegratedCosetMds; use p3_mds::MdsPermutation; use p3_mersenne_31::{MdsMatrixMersenne31, Mersenne31}; use rand::distributions::{Distribution, Standard}; use rand::{thread_rng, Rng}; fn bench_all_mds(c: &mut Criterion) { bench_mds::, 16>(c); bench_mds::<::Packing, IntegratedCosetMds, 16>(c); bench_mds::, 16>(c); bench_mds::<::Packing, CosetMds, 16>(c); bench_mds::(c); bench_mds::(c); bench_mds::(c); bench_mds::(c); bench_mds::(c); bench_mds::(c); bench_mds::(c); bench_mds::(c); bench_mds::(c); bench_mds::(c); bench_mds::(c); bench_mds::(c); bench_mds::(c); bench_mds::(c); bench_mds::(c); bench_mds::(c); } fn bench_mds(c: &mut Criterion) where AF: AbstractField, Standard: Distribution, Mds: MdsPermutation + Default, { let mds = Mds::default(); let mut rng = thread_rng(); let input = rng.gen::<[AF; WIDTH]>(); let id = BenchmarkId::new(type_name::(), WIDTH); c.bench_with_input(id, &input, |b, input| b.iter(|| mds.permute(input.clone()))); } criterion_group!(benches, bench_all_mds); criterion_main!(benches);