#[macro_use] extern crate criterion; extern crate variant; use criterion::Criterion; use criterion::black_box; use variety::experiments; fn generate_variant_max(n: u64) -> Vec { (0..n).map(|_| { 255 }).collect() } fn low_length_experiment_generation(c: &mut Criterion) { c.bench_function("generate 100 experiments", |b| { let variants = black_box(generate_variant_max(100)); b.iter(|| experiments(black_box(0), &variants)) }); } fn high_length_experiment_generation(c: &mut Criterion) { c.bench_function("generate 10,000 experiments", |b| { let variants = black_box(generate_variant_max(10_000)); b.iter(|| experiments(black_box(0), &variants)) }); } fn extreme_length_experiment_generation(c: &mut Criterion) { let mut sized = c.benchmark_group("reduced_sample"); sized.bench_function("generate 100,000,000 experiments", |b| { let variants = black_box(generate_variant_max(100_000_000)); b.iter(|| experiments(black_box(0), &variants)) }); } criterion_group!(experiments_generation, low_length_experiment_generation, high_length_experiment_generation, extreme_length_experiment_generation); criterion_main!(experiments_generation);