Skip to main content

SimpleRate

Struct SimpleRate 

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

A simple rate: the rate is incrementally calculated based on the elapsed time between the earliest reading and now.

An exception is made for the first window, which is considered of fixed size. This avoids the issue of an artificially high rate when the gap between readings is close to 0.

In Java SimpleRate extends Rate and overrides only windowSize. Rust has no inheritance, so we compose a Rate and re-implement measure using the overridden window_size (Java’s measure is on Rate, calling the virtual windowSize).

Implementations§

Source§

impl SimpleRate

Source

pub fn new() -> Self

Create a SimpleRate over seconds backed by a WindowedSum.

Source

pub fn window_size(&self, config: &MetricConfig, now: i64) -> i64

Compute the window size in milliseconds, overriding Rate::window_size: max(elapsed, config.timeWindowMs()).

Trait Implementations§

Source§

impl Default for SimpleRate

Source§

fn default() -> Self

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

impl Measurable for SimpleRate

Source§

fn measure(&self, config: &MetricConfig, now: i64) -> f64

Measure this quantity and return the result as an f64. Read more
Source§

impl Stat for SimpleRate

Source§

fn record(&self, config: &MetricConfig, value: f64, time_ms: i64)

Record the given 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, 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.
§

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

§

fn vzip(self) -> V

Source§

impl<T> MeasurableStat for T
where T: Stat + Measurable,