pub struct DeltaFloat<T> { /* private fields */ }Expand description
Simple metric for absolute difference of 1-dimentional f32 or f64’s
§Example:
let mut diff = metrics::DeltaFloat::new();
assert!(diff.observe(1.5_f32).is_nan());
assert_eq!(diff.observe(2.5_f32), 1.0);Implementations§
Trait Implementations§
Source§impl<T: Clone> Clone for DeltaFloat<T>
impl<T: Clone> Clone for DeltaFloat<T>
Source§fn clone(&self) -> DeltaFloat<T>
fn clone(&self) -> DeltaFloat<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for DeltaFloat<T>
impl<T: Debug> Debug for DeltaFloat<T>
Source§impl<T: Default> Default for DeltaFloat<T>
impl<T: Default> Default for DeltaFloat<T>
Source§fn default() -> DeltaFloat<T>
fn default() -> DeltaFloat<T>
Returns the “default value” for a type. Read more
Source§impl<T> Display for DeltaFloat<T>
impl<T> Display for DeltaFloat<T>
Source§impl<I: Float> Metric<I> for DeltaFloat<I>
impl<I: Float> Metric<I> for DeltaFloat<I>
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: I) -> Option<Self::Output>
fn observe_opt(&mut self, x: I) -> 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<I: Float> StatefulMetric<I> for DeltaFloat<I>
impl<I: Float> StatefulMetric<I> for DeltaFloat<I>
fn observe_opt(&mut self, x: Input) -> Option<Self::Output>
Auto Trait Implementations§
impl<T> Freeze for DeltaFloat<T>where
T: Freeze,
impl<T> RefUnwindSafe for DeltaFloat<T>where
T: RefUnwindSafe,
impl<T> Send for DeltaFloat<T>where
T: Send,
impl<T> Sync for DeltaFloat<T>where
T: Sync,
impl<T> Unpin for DeltaFloat<T>where
T: Unpin,
impl<T> UnwindSafe for DeltaFloat<T>where
T: UnwindSafe,
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