pub struct SimpleRate { /* private fields */ }Expand description
A simple rate: the rate is incrementally calculated based on the elapsed time between the earliest reading and now.
An exception is made for the first window, which is considered of fixed size. This avoids the issue of an artificially high rate when the gap between readings is close to 0.
In Java SimpleRate extends Rate and overrides only windowSize. Rust has
no inheritance, so we compose a Rate and re-implement measure using the
overridden window_size (Java’s measure is on Rate, calling the virtual
windowSize).
Implementations§
Source§impl SimpleRate
impl SimpleRate
Sourcepub fn window_size(&self, config: &MetricConfig, now: i64) -> i64
pub fn window_size(&self, config: &MetricConfig, now: i64) -> i64
Compute the window size in milliseconds, overriding Rate::window_size:
max(elapsed, config.timeWindowMs()).
Trait Implementations§
Source§impl Default for SimpleRate
impl Default for SimpleRate
Source§impl Measurable for SimpleRate
impl Measurable for SimpleRate
Auto Trait Implementations§
impl Freeze for SimpleRate
impl !RefUnwindSafe for SimpleRate
impl Send for SimpleRate
impl Sync for SimpleRate
impl Unpin for SimpleRate
impl UnsafeUnpin for SimpleRate
impl !UnwindSafe for SimpleRate
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