Trait suggest::benchmarks::BenchmarkWithInput

source ·
pub trait BenchmarkWithInput {
    type Input;

    // Required methods
    fn generate_input(&self) -> Self::Input;
    fn benchmarked_code(&self, input: Self::Input);
}
Expand description

Trait for benchmarks that require input

This will run using Criterion’s iter_batched function. Criterion will create a batch of inputs, then pass each one to benchmark.

This supports simple benchmarks that don’t require any input. Note: global setup can be done in the new() method for the struct.

Required Associated Types§

Required Methods§

source

fn generate_input(&self) -> Self::Input

Generate the input (this is not included in the benchmark time)

source

fn benchmarked_code(&self, input: Self::Input)

Perform the operations that we’re benchmarking.

Implementors§