[][src]Trait criterion::measurement::Measurement

pub trait Measurement {
    type Intermediate;
    type Value;
    fn start(&self) -> Self::Intermediate;
fn end(&self, i: Self::Intermediate) -> Self::Value;
fn add(&self, v1: &Self::Value, v2: &Self::Value) -> Self::Value;
fn zero(&self) -> Self::Value;
fn to_f64(&self, value: &Self::Value) -> f64;
fn formatter(&self) -> &dyn ValueFormatter; }

Trait for all types which define something Criterion.rs can measure. The only measurement currently provided is WallTime, but third party crates or benchmarks may define more.

This trait defines two core methods, start and end. start is called at the beginning of a measurement to produce some intermediate value (for example, the wall-clock time at the start of that set of iterations) and end is called at the end of the measurement with the value returned by start.

Associated Types

type Intermediate

This type represents an intermediate value for the measurements. It will be produced by the start function and passed to the end function. An example might be the wall-clock time as of the start call.

type Value

This type is the measured value. An example might be the elapsed wall-clock time between the start and end calls.

Loading content...

Required methods

fn start(&self) -> Self::Intermediate

Criterion.rs will call this before iterating the benchmark.

fn end(&self, i: Self::Intermediate) -> Self::Value

Criterion.rs will call this after iterating the benchmark to get the measured value.

fn add(&self, v1: &Self::Value, v2: &Self::Value) -> Self::Value

Combine two values. Criterion.rs sometimes needs to perform measurements in multiple batches of iterations, so the value from one batch must be added to the sum of the previous batches.

fn zero(&self) -> Self::Value

Return a "zero" value for the Value type which can be added to another value.

fn to_f64(&self, value: &Self::Value) -> f64

Converts the measured value to f64 so that it can be used in statistical analysis.

fn formatter(&self) -> &dyn ValueFormatter

Return a trait-object reference to the value formatter for this measurement.

Loading content...


impl Measurement for WallTime[src]

type Intermediate = Instant

type Value = Duration

Loading content...