pub trait Benchmark {
type Input: Input + 'static;
type Output: Serialize;
// Required methods
fn try_match(input: &Self::Input) -> Result<MatchScore, FailureScore>;
fn description(f: &mut Formatter<'_>, input: Option<&Self::Input>) -> Result;
fn run(
input: &Self::Input,
checkpoint: Checkpoint<'_>,
output: &mut dyn Output,
) -> Result<Self::Output>;
}Expand description
Required Associated Types§
Required Methods§
Sourcefn try_match(input: &Self::Input) -> Result<MatchScore, FailureScore>
fn try_match(input: &Self::Input) -> Result<MatchScore, FailureScore>
Return whether or not this benchmark is compatible with input.
On success, returns Ok(MatchScore). MatchScores of all benchmarks will be
collected and the benchmark with the lowest final score will be selected.
In the case of ties, the winner is chosen using an unspecified tie-breaking procedure.
On failure, returns Err(FailureScore). In the crate::registry::Benchmarks
registry, FailureScores will be used to rank the “nearest misses”. Implementations
are encouraged to generate ranked FailureScores to assist in user level debugging.
Sourcefn description(f: &mut Formatter<'_>, input: Option<&Self::Input>) -> Result
fn description(f: &mut Formatter<'_>, input: Option<&Self::Input>) -> Result
Return descriptive information about the benchmark.
If input is None, then high level information about the benchmark should be relayed.
If input is Some, and is an unsuccessful match, diagnostic information about what
was expected should be generated to help users.
Sourcefn run(
input: &Self::Input,
checkpoint: Checkpoint<'_>,
output: &mut dyn Output,
) -> Result<Self::Output>
fn run( input: &Self::Input, checkpoint: Checkpoint<'_>, output: &mut dyn Output, ) -> Result<Self::Output>
Run the benchmark with input.
All prints should be directed to output. The checkpoint is provided so
long-running benchmarks can periodically save output to prevent data loss due to
an early error.
Implementors may assume that Self::try_match returned Ok on input.
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.