Trait RateCounter

Source
pub trait RateCounter {
    // Required methods
    fn samples(&self) -> u64;
    fn set_samples(&mut self, samples: u64);
    fn update(&mut self);
    fn rate(&self) -> f64;
}
Expand description

Basic rate counter functionality.

Types which implement RateCounter also implement Display (a string with “ Hz”) and Debug (including samples as well).

Required Methods§

Source

fn samples(&self) -> u64

Return the current number of samples the UpdateRateCounter is measuring.

Source

fn set_samples(&mut self, samples: u64)

Set the number of updates which the UpdateRateCounter considers.

§Panics

This function may panic if given a samples value equal to 0.

Source

fn update(&mut self)

Updates the struct in place, but requires a mutable binding. Call either this OR update_immut() at the beginning of each cycle of the periodic activity being measured.

Source

fn rate(&self) -> f64

Return the last calculated rate of operation, in Hertz (updates per second).

Implementors§