Struct running_average::RunningAverage [−][src]
pub struct RunningAverage<V: Default, I: TimeInstant + Copy> { /* fields omitted */ }
Represents running average calculation window. It is using specified window width that will consist of given number of accumulator buckets to ensure constant memory usage.
Methods
impl<V: Default, I: TimeInstant + Copy> RunningAverage<V, I>
[src]
impl<V: Default, I: TimeInstant + Copy> RunningAverage<V, I>
pub fn new(duration: Duration) -> RunningAverage<V, I>
[src]
pub fn new(duration: Duration) -> RunningAverage<V, I>
Crate new RunningAverage instance that will average over window of width of given duration using 16 buckets.
pub fn with_capacity(
duration: Duration,
capacity: usize
) -> RunningAverage<V, I>
[src]
pub fn with_capacity(
duration: Duration,
capacity: usize
) -> RunningAverage<V, I>
Crate new RunningAverage instance that will average over window of width of given duration with specific number of buckets to use.
pub fn insert(&mut self, now: I, val: V) where
V: AddAssign<V>,
[src]
pub fn insert(&mut self, now: I, val: V) where
V: AddAssign<V>,
Insert value to be average over at given time instant. Panics if now is less than previous now - time cannot go backwards
pub fn measurement<'i>(&'i mut self, now: I) -> Measurement<V> where
V: Sum<&'i V>,
[src]
pub fn measurement<'i>(&'i mut self, now: I) -> Measurement<V> where
V: Sum<&'i V>,
Calculate running average using time window ending at given time instant. Panics if now is less than previous now - time cannot go backwards.
Trait Implementations
impl<V: Debug + Default, I: Debug + TimeInstant + Copy> Debug for RunningAverage<V, I>
[src]
impl<V: Debug + Default, I: Debug + TimeInstant + Copy> Debug for RunningAverage<V, I>
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, I: TimeInstant + Copy> Default for RunningAverage<V, I>
[src]
impl<V: Default, I: TimeInstant + Copy> Default for RunningAverage<V, I>
fn default() -> RunningAverage<V, I>
[src]
fn default() -> RunningAverage<V, I>
Crate new RunningAverage instance with window of 8 seconds width and 16 buckets.
Auto Trait Implementations
impl<V, I> Send for RunningAverage<V, I> where
I: Send,
V: Send,
impl<V, I> Send for RunningAverage<V, I> where
I: Send,
V: Send,
impl<V, I> Sync for RunningAverage<V, I> where
I: Sync,
V: Sync,
impl<V, I> Sync for RunningAverage<V, I> where
I: Sync,
V: Sync,