pub struct RollingRateCounter { /* private fields */ }
Expand description
A rolling update counter. It records as many updates as the given sample rate and re-calculates the average update time on each call to update.
Generally, this is to be preferred over the discrete version. However, for very
high values of sample
, this can be quite inefficient, especially if the rate
value isn’t needed during each cycle.
§Usage
Call .update()
every time your system starts a new update/cycle; for
instance, an FPS counter would call this at the beginning of every frame.
The sample rate (set with set_sample_rate()
and in the first argument to
new()
) governs how many .update()
calls are required before a
meaningful result is produced.
You can also use .update_immut() for this to avoid a mutable binding.
Implementations§
Trait Implementations§
Source§impl Clone for RollingRateCounter
impl Clone for RollingRateCounter
Source§fn clone(&self) -> RollingRateCounter
fn clone(&self) -> RollingRateCounter
Returns a copy 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 Debug for RollingRateCounter
impl Debug for RollingRateCounter
Source§impl Display for RollingRateCounter
impl Display for RollingRateCounter
Source§impl RateCounter for RollingRateCounter
impl RateCounter for RollingRateCounter
Source§fn samples(&self) -> u64
fn samples(&self) -> u64
Return the current number of samples the UpdateRateCounter is measuring.
Source§fn set_samples(&mut self, samples: u64)
fn set_samples(&mut self, samples: u64)
Set the number of updates which the UpdateRateCounter considers. Read more
Auto Trait Implementations§
impl Freeze for RollingRateCounter
impl RefUnwindSafe for RollingRateCounter
impl Send for RollingRateCounter
impl Sync for RollingRateCounter
impl Unpin for RollingRateCounter
impl UnwindSafe for RollingRateCounter
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