Struct running_average::RealTimeRunningAverage [−][src]
pub struct RealTimeRunningAverage<V: Default, TS: TimeSource = RealTimeSource> { /* fields omitted */ }
Represents running average calculation window where shift
and measurement
are using given time source to obtain value of now
instant.
It is using specified window width that will consist of given number of accumulator buckets to ensure constant memory usage.
Methods
impl<V: Default> RealTimeRunningAverage<V, RealTimeSource>
[src]
impl<V: Default> RealTimeRunningAverage<V, RealTimeSource>
pub fn new(duration: Duration) -> RealTimeRunningAverage<V, RealTimeSource>
[src]
pub fn new(duration: Duration) -> RealTimeRunningAverage<V, RealTimeSource>
Crate new instance with window of given width duration and using RealTimeSource as time source for now
instant.
Note: new() is parametrizing output to RealTimeSource as this cannot be inferred otherwise.
impl<V: Default, TS: TimeSource> RealTimeRunningAverage<V, TS>
[src]
impl<V: Default, TS: TimeSource> RealTimeRunningAverage<V, TS>
pub fn with_time_source(
duration: Duration,
capacity: usize,
time_source: TS
) -> RealTimeRunningAverage<V, TS>
[src]
pub fn with_time_source(
duration: Duration,
capacity: usize,
time_source: TS
) -> RealTimeRunningAverage<V, TS>
Crate new instance with window of given width duration and using given as time source for now
instant.
pub fn insert(&mut self, val: V) where
V: AddAssign<V>,
[src]
pub fn insert(&mut self, val: V) where
V: AddAssign<V>,
Insert value to be average over now. Panics if time source time goes backwards.
pub fn measurement<'i>(&'i mut self) -> Measurement<V> where
V: Sum<&'i V>,
[src]
pub fn measurement<'i>(&'i mut self) -> Measurement<V> where
V: Sum<&'i V>,
Calculate running average using time window ending now. Panics if time source time goes backwards.
pub fn time_source(&mut self) -> &mut TS
[src]
pub fn time_source(&mut self) -> &mut TS
Return mutable reference to time source used.
Trait Implementations
impl<V: Debug + Default, TS: Debug + TimeSource> Debug for RealTimeRunningAverage<V, TS> where
TS::Instant: Debug,
[src]
impl<V: Debug + Default, TS: Debug + TimeSource> Debug for RealTimeRunningAverage<V, TS> where
TS::Instant: Debug,
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<V: Default> Default for RealTimeRunningAverage<V, RealTimeSource>
[src]
impl<V: Default> Default for RealTimeRunningAverage<V, RealTimeSource>
fn default() -> RealTimeRunningAverage<V, RealTimeSource>
[src]
fn default() -> RealTimeRunningAverage<V, RealTimeSource>
Returns the "default value" for a type. Read more
Auto Trait Implementations
impl<V, TS> Send for RealTimeRunningAverage<V, TS> where
TS: Send,
V: Send,
<TS as TimeSource>::Instant: Send,
impl<V, TS> Send for RealTimeRunningAverage<V, TS> where
TS: Send,
V: Send,
<TS as TimeSource>::Instant: Send,
impl<V, TS> Sync for RealTimeRunningAverage<V, TS> where
TS: Sync,
V: Sync,
<TS as TimeSource>::Instant: Sync,
impl<V, TS> Sync for RealTimeRunningAverage<V, TS> where
TS: Sync,
V: Sync,
<TS as TimeSource>::Instant: Sync,