pub struct MovingAvg { /* private fields */ }Expand description
Records the average value in the last N values
Implementations§
Trait Implementations§
Source§impl Metric<f64> for MovingAvg
impl Metric<f64> for MovingAvg
Source§type Output = f64
type Output = f64
The type of elements recorded by the metric.
For a delta of last vs current, this might be an n-dimentional vector. It typically needs to
be an Owned type, rather than a reference. Read more
Source§fn observe_opt(&mut self, x: f64) -> Option<Self::Output>
fn observe_opt(&mut self, x: f64) -> Option<Self::Output>
Similar to
observe except None is returned instead of f64::NAN to indicate not enough data collected.
Useful if you like Read moreSource§fn observe(&mut self, x: Input) -> f64
fn observe(&mut self, x: Input) -> f64
Records the value, and return the calculated metric.
If there are not enough samples to calculate the metric,
f64::NAN is returned,
which will always compare false. So a tolerance check observe(x) < 0.0001 will
fail until enough samples have been collected.
If you don’t like NANs, then Metric::observe_opt is your friend.Source§impl StatefulMetric<f64> for MovingAvg
impl StatefulMetric<f64> for MovingAvg
fn observe_opt(&mut self, x: Input) -> Option<Self::Output>
Auto Trait Implementations§
impl Freeze for MovingAvg
impl RefUnwindSafe for MovingAvg
impl Send for MovingAvg
impl Sync for MovingAvg
impl Unpin for MovingAvg
impl UnwindSafe for MovingAvg
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more