suggest::benchmarks

Trait BenchmarkWithInput

source
pub trait BenchmarkWithInput {
    type GlobalInput;
    type IterationInput;

    // Required methods
    fn global_input(&self) -> Self::GlobalInput;
    fn iteration_input(&self) -> Self::IterationInput;
    fn benchmarked_code(
        &self,
        g_input: &Self::GlobalInput,
        i_input: Self::IterationInput,
    );
}
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 the benchmark’s iterations.

This supports simple benchmarks that don’t require any input.

Required Associated Types§

source

type GlobalInput

Input that will be created once and then passed by reference to each of the benchmark’s iterations.

source

type IterationInput

Input that will be created for each of the benchmark’s iterations.

Required Methods§

source

fn global_input(&self) -> Self::GlobalInput

Generate the global input (not included in the benchmark time)

source

fn iteration_input(&self) -> Self::IterationInput

Generate the per-iteration input (not included in the benchmark time)

source

fn benchmarked_code( &self, g_input: &Self::GlobalInput, i_input: Self::IterationInput, )

Perform the operations that we’re benchmarking.

Implementors§