PropertyBenchmarkGroup

Trait PropertyBenchmarkGroup 

Source
pub trait PropertyBenchmarkGroup<'a> {
    // Required method
    fn bench_generated<I, G, F>(&mut self, id: &str, generator: G, f: F)
       where I: Clone + 'static,
             G: Generator<I>,
             F: FnMut(&I) + 'static;
}
Expand description

Helper for creating benchmark groups with property-based inputs

This provides a more ergonomic API for benchmarking multiple configurations with generated inputs.

Required Methods§

Source

fn bench_generated<I, G, F>(&mut self, id: &str, generator: G, f: F)
where I: Clone + 'static, G: Generator<I>, F: FnMut(&I) + 'static,

Benchmark over generated inputs with a specific parameter

§Example
use criterion::{criterion_group, criterion_main, Criterion};
use protest_criterion::PropertyBenchmarkGroup;
use protest::primitives::VecGenerator;
use protest::Generator;

fn bench_by_size(c: &mut Criterion) {
    let mut group = c.benchmark_group("sort_by_size");

    for size in [10, 100, 1000] {
        let generator = VecGenerator::new(
            protest::primitives::IntGenerator::new(0, 1000),
            size,
            size
        );

        group.bench_generated(&size.to_string(), generator, |v: &Vec<i32>| {
            let mut sorted = v.clone();
            sorted.sort();
        });
    }

    group.finish();
}

criterion_group!(benches, bench_by_size);
criterion_main!(benches);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a> PropertyBenchmarkGroup<'a> for BenchmarkGroup<'a, WallTime>

Source§

fn bench_generated<I, G, F>(&mut self, id: &str, generator: G, f: F)
where I: Clone + 'static, G: Generator<I>, F: FnMut(&I) + 'static,

Implementors§