pub struct FpsCounter { /* private fields */ }
Expand description
An accurate FPS counter, that remembers samples frame times in order to calculate the current FPS as accurratly as possible.
The frame sampler has a limited size, when it grows to big, the oldest frames are dropped. Frames that become outdated (frames that have been timed more than 5 seconds ago) are also dropped.
To count frames, the tick()
method must be called repeatedly, to sample
a frame.
Implementations§
Source§impl FpsCounter
impl FpsCounter
Sourcepub fn new() -> FpsCounter
pub fn new() -> FpsCounter
Create a new FPS counter.
Sourcepub fn calculate_fps(&mut self) -> Option<f64>
pub fn calculate_fps(&mut self) -> Option<f64>
Calculate the FPS based on the known frame times.
If we are unable to calculate the FPS, None is returned.
Sourcepub fn report_periodically(&mut self)
pub fn report_periodically(&mut self)
Report the FPS to the console periodically. By default this happens each second.
If this method is invoked but the FPS has been reported too recently, nothing happens.
Auto Trait Implementations§
impl Freeze for FpsCounter
impl RefUnwindSafe for FpsCounter
impl Send for FpsCounter
impl Sync for FpsCounter
impl Unpin for FpsCounter
impl UnwindSafe for FpsCounter
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