pub struct FrameRateMonitor {
capacity: usize,
window: VecDeque<Duration>,
warn_threshold: f64,
recover_threshold: f64,
in_warn_state: bool,
}Expand description
Sliding-window frame-rate monitor.
Constructed once per preview pipeline; observe is called every
frame with the current wall-clock timestamp. The internal buffer
caps at capacity to keep memory bounded.
Fields§
§capacity: usize§window: VecDeque<Duration>§warn_threshold: f64§recover_threshold: f64§in_warn_state: booltrue when we’ve already emitted the low-fps warning and
haven’t recovered yet. Suppresses repeat warns.
Implementations§
Source§impl FrameRateMonitor
impl FrameRateMonitor
Sourcepub fn new(capacity: usize, warn_threshold: f64, recover_threshold: f64) -> Self
pub fn new(capacity: usize, warn_threshold: f64, recover_threshold: f64) -> Self
Build a monitor with the given window size + thresholds.
Sourcepub fn observe(&mut self, timestamp: Duration) -> Option<Transition>
pub fn observe(&mut self, timestamp: Duration) -> Option<Transition>
Record a frame timestamp + return Some(fps) when the window
crosses a threshold and the caller should emit a warn/recover
log line. None for the common case where no transition
happened.
Sourcepub fn current_fps(&self) -> f64
pub fn current_fps(&self) -> f64
Snapshot the current sustained fps over the window.
Trait Implementations§
Source§impl Debug for FrameRateMonitor
impl Debug for FrameRateMonitor
Auto Trait Implementations§
impl Freeze for FrameRateMonitor
impl RefUnwindSafe for FrameRateMonitor
impl Send for FrameRateMonitor
impl Sync for FrameRateMonitor
impl Unpin for FrameRateMonitor
impl UnsafeUnpin for FrameRateMonitor
impl UnwindSafe for FrameRateMonitor
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().