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§
sourcetype GlobalInput
type GlobalInput
Input that will be created once and then passed by reference to each of the benchmark’s iterations.
sourcetype IterationInput
type IterationInput
Input that will be created for each of the benchmark’s iterations.
Required Methods§
sourcefn global_input(&self) -> Self::GlobalInput
fn global_input(&self) -> Self::GlobalInput
Generate the global input (not included in the benchmark time)
sourcefn iteration_input(&self) -> Self::IterationInput
fn iteration_input(&self) -> Self::IterationInput
Generate the per-iteration input (not included in the benchmark time)
sourcefn benchmarked_code(
&self,
g_input: &Self::GlobalInput,
i_input: Self::IterationInput,
)
fn benchmarked_code( &self, g_input: &Self::GlobalInput, i_input: Self::IterationInput, )
Perform the operations that we’re benchmarking.