use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; use p3_field::AbstractField; use p3_field_testing::bench_func::{ benchmark_add_latency, benchmark_add_throughput, benchmark_inv, benchmark_iter_sum, benchmark_sub_latency, benchmark_sub_throughput, }; use p3_mersenne_31::Mersenne31; type F = Mersenne31; fn bench_field(c: &mut Criterion) { let name = "Mersenne31"; const REPS: usize = 1000; benchmark_inv::(c, name); benchmark_iter_sum::(c, name); benchmark_iter_sum::(c, name); benchmark_iter_sum::(c, name); // Note that each round of throughput has 10 operations // So we should have 10 * more repetitions for latency tests. const L_REPS: usize = 10 * REPS; benchmark_add_latency::(c, name); benchmark_add_throughput::(c, name); benchmark_sub_latency::(c, name); benchmark_sub_throughput::(c, name); c.bench_function("5th_root", |b| { b.iter_batched( rand::random::, |x| x.exp_u64(1717986917), BatchSize::SmallInput, ) }); } criterion_group!(mersenne31_arithmetics, bench_field); criterion_main!(mersenne31_arithmetics);