pub trait Benchmark: 'static {
type Input: Input + 'static;
type Output: Serialize;
// Required methods
fn try_match(&self, input: &Self::Input, context: &MatchContext) -> Score;
fn description(&self, f: &mut Formatter<'_>) -> Result;
fn run(
&self,
input: &Self::Input,
checkpoint: Checkpoint<'_>,
output: &mut dyn Output,
) -> Result<Self::Output>;
}Expand description
Required Associated Types§
Required Methods§
Sourcefn try_match(&self, input: &Self::Input, context: &MatchContext) -> Score
fn try_match(&self, input: &Self::Input, context: &MatchContext) -> Score
Return whether or not this benchmark is compatible with input.
Use MatchContext::success to create an initial Score, then progressively
refine it with Score::penalize and Score::fail.
Among successful matches, the benchmark with the lowest score wins. Ties are broken by an unspecified procedure.
When no successful match exists, failure scores rank the “nearest misses”.
Implementations should use Score::fail with descriptive reasons to aid
diagnostics.
Sourcefn description(&self, f: &mut Formatter<'_>) -> Result
fn description(&self, f: &mut Formatter<'_>) -> Result
Return descriptive information about the benchmark.
Sourcefn run(
&self,
input: &Self::Input,
checkpoint: Checkpoint<'_>,
output: &mut dyn Output,
) -> Result<Self::Output>
fn run( &self, 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 a successful Score
for input.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".