Skip to main content

PacingDiagnostics

Struct PacingDiagnostics 

Source
pub struct PacingDiagnostics { /* private fields */ }
Expand description

Accumulates presented-frame timestamps into cadence diagnostics.

Feed every presented frame in presentation order through Self::record_presented (or Self::record_untimed_presented when presentation completed without a display time), then read summaries with Self::report.

Implementations§

Source§

impl PacingDiagnostics

Source

pub fn new() -> Self

Creates diagnostics summarizing the most recent 240 presented intervals.

Source

pub fn with_window(window: usize) -> Self

Creates diagnostics summarizing at most window recent presented intervals.

A zero window is treated as a window of one interval.

Source

pub fn record_presented(&mut self, presented_at: Instant)

Records one presented frame with the display time the backend reported for it.

A timestamp not later than its predecessor contributes no interval; the frame is still counted.

Source

pub fn record_untimed_presented(&mut self)

Records one frame whose presentation completed without a reported display time, such as while the window is off screen.

Source

pub fn estimated_cadence(&self) -> Option<Duration>

Estimates the display cadence as the median of the recent presented intervals.

Returns None until enough intervals have been observed to estimate responsibly.

Source

pub fn report(&self) -> PacingReport

Summarizes everything recorded so far.

Trait Implementations§

Source§

impl Debug for PacingDiagnostics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PacingDiagnostics

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.