Skip to main content

Stats

Struct Stats 

Source
pub struct Stats {
    sorted: Vec<u64>,
    taken: Vec<u64>,
    mean: u64,
}
Expand description

A series of samples and the order statistics read off it.

Holds the samples twice: sorted, because everything below is an order statistic, and in the order the run took them, because that is what the report carries and a baseline is only useful if the samples themselves survive into it — a summary cannot be compared against a later run with anything better than arithmetic on summaries.

The two copies exist for a reason a sorted one alone cannot serve. Issue #205 asks whether a run-to-run disagreement is drift within a suite or between two of them, and a sorted array cannot answer it: whether the slow samples were the first three or the last three is exactly the information sorting throws away. Nothing in this file reads the run order — every statistic below is an order statistic and the bootstrap resamples with replacement — so keeping it costs one vector and buys a question that could not be asked before.

Fields§

§sorted: Vec<u64>§taken: Vec<u64>

The same samples, in the order the run took them. Reported; not read.

§mean: u64

Implementations§

Source§

impl Stats

Source

pub fn of(samples: &[u64]) -> Stats

Summarizes samples, which must not be empty.

Source

pub fn samples(&self) -> &[u64]

The samples, in ascending order.

Source

pub fn min(&self) -> u64

Source

pub fn max(&self) -> u64

Source

pub fn mean(&self) -> u64

The arithmetic mean, truncated. Kept because ADR 0012 names it.

Source

pub fn median(&self) -> f64

Source

pub fn p25(&self) -> f64

Source

pub fn p75(&self) -> f64

Source

pub fn iqr(&self) -> f64

The interquartile range: the width of the middle half of the series.

This is the spread to read. Unlike max - min it does not grow just because the series got longer and so had more chances to catch one bad sample.

Source

pub fn to_json(&self) -> String

The summary, as a JSON object.

min, mean and max are first and keep their names, because ADR 0012 describes this object as {min, mean, max} and a reader written against that description must keep working.

Source

pub fn to_json_with_samples(&self) -> String

The summary with every sample beside it.

What makes a recorded run a baseline rather than a memory of one: a comparison needs the samples, not a summary of them, because the interval it reports is built by resampling them.

In the order the run took them, which is strictly more than a sorted array says and costs a reader who wanted the sorted one a sort. Nothing that compares two runs is affected — every statistic here is an order statistic and Comparison::of sorts what it is given — and what it buys is that a reader can see when in a series a slow sample arrived, which is the difference between a machine that drifted and a benchmark that is noisy.

Auto Trait Implementations§

§

impl Freeze for Stats

§

impl RefUnwindSafe for Stats

§

impl Send for Stats

§

impl Sync for Stats

§

impl Unpin for Stats

§

impl UnsafeUnpin for Stats

§

impl UnwindSafe for Stats

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.