Timer

Struct Timer 

Source
pub struct Timer { /* private fields */ }
Expand description

A metric tracking the duration and rate of events.

The timer’s default reservoir implementation (used by its Default implementation) is the ExponentiallyDecayingReservoir.

Implementations§

Source§

impl Timer

Source

pub fn new<R>(reservoir: R) -> Timer
where R: Reservoir,

Creates a new timer.

Source

pub fn new_with<R>(reservoir: R, clock: Arc<dyn Clock>) -> Timer
where R: Reservoir,

Creates a new timer using the provided Clock as its time source.

Source

pub fn update(&self, duration: Duration)

Adds a new timed event to the metric.

Source

pub fn time(&self) -> Time<'_>

Returns a guard type which reports the time elapsed since its creation when it drops.

Source

pub fn count(&self) -> i64

Returns the number of events reported to the metric.

Source

pub fn one_minute_rate(&self) -> f64

Returns the one minute rolling average rate of the occurrence of events measured in events per second.

Source

pub fn five_minute_rate(&self) -> f64

Returns the five minute rolling average rate of the occurrence of events measured in events per second.

Source

pub fn fifteen_minute_rate(&self) -> f64

Returns the fifteen minute rolling average rate of the occurrence of events measured in events per second.

Source

pub fn mean_rate(&self) -> f64

Returns the mean rate of the occurrence of events since the creation of the timer measured in events per second.

Source

pub fn snapshot(&self) -> Box<dyn Snapshot>

Returns a snapshot of the statistical distribution of durations of events, measured in nanoseconds.

Trait Implementations§

Source§

impl Default for Timer

Source§

fn default() -> Timer

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for Timer

§

impl !RefUnwindSafe for Timer

§

impl Send for Timer

§

impl Sync for Timer

§

impl Unpin for Timer

§

impl !UnwindSafe for Timer

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V