Struct histogram::Snapshot

source ·
pub struct Snapshot { /* private fields */ }
Expand description

A snapshot of a histogram across a time range.

Implementations§

source§

impl Snapshot

source

pub fn range(&self) -> Range<SystemTime>

Return the time range of the snapshot.

source

pub fn percentiles( &self, percentiles: &[f64] ) -> Result<Vec<(f64, Bucket)>, Error>

Return a collection of percentiles from this snapshot.

Each percentile should be in the inclusive range 0.0..=100.0. For example, the 50th percentile (median) can be found using 50.0.

The results will be sorted by the percentile.

source

pub fn percentile(&self, percentile: f64) -> Result<Bucket, Error>

Return a single percentile from this snapshot.

The percentile should be in the inclusive range 0.0..=100.0. For example, the 50th percentile (median) can be found using 50.0.

source

pub fn downsample(&self, factor: u8) -> Result<Snapshot, Error>

Returns a new downsampled histogram with a reduced grouping power.

The new histogram is smaller but with greater relative error. The reduction factor should be smaller than the histogram’s existing grouping power.

source

pub fn checked_merge(&self, rhs: &Self) -> Result<Self, Error>

Merges two snapshots which cover the same time range.

An error is raised on overflow.

source

pub fn checked_add(&self, rhs: &Self) -> Result<Self, Error>

Appends the provided snapshot onto this snapshot, extending the covered time range and combining the bucket counts.

An error is raised on overflow.

source

pub fn wrapping_add(&self, rhs: &Self) -> Result<Self, Error>

Appends the provided snapshot onto this snapshot, extending the covered time range and combining the bucket counts.

Bucket counters will wrap on overflow.

source

pub fn checked_sub(&self, rhs: &Self) -> Result<Self, Error>

Appends the provided snapshot onto this snapshot, shrinking the covered time range and producing a delta of the bucket counts.

An error is raised on overflow.

source

pub fn wrapping_sub(&self, rhs: &Self) -> Result<Self, Error>

Appends the provided snapshot onto this snapshot, extending the covered time range and combining the bucket counts.

Bucket counters will wrap on overflow.

source

pub fn config(&self) -> Config

Returns the bucket configuration of the snapshot.

Trait Implementations§

source§

impl Clone for Snapshot

source§

fn clone(&self) -> Snapshot

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl From<&Snapshot> for SparseHistogram

source§

fn from(snapshot: &Snapshot) -> Self

Converts to this type from the input type.
source§

impl<'a> IntoIterator for &'a Snapshot

§

type Item = Bucket

The type of the elements being iterated over.
§

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.