Struct Log

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

A struct holding information about the previous logging interval

Implementations§

Source§

impl Log

Source

pub fn delta_time_avg(&self) -> Duration

frame time averaged over the interval since the last call to Timer::log

Source

pub fn delta_time_avg_ms(&self) -> f64

frame time averaged over the interval since the last call to Timer::log in milliseconds

Examples found in repository?
examples/fps/main.rs (line 22)
5fn main() {
6    let args: Vec<String> = env::args().collect();
7    let fps = args
8        .get(1)
9        .and_then(|arg| arg.parse().ok())
10        .unwrap_or(420.69);
11
12    let mut timer = Timer::default()
13        .log_interval(Duration::from_millis(100))
14        .high_precision(true)
15        .fps(fps);
16
17    loop {
18        let _dt = timer.frame();
19        if let Some(log) = timer.log() {
20            print!(
21                "{:>15.6}ms ({:>10.3}fps)      \r",
22                log.delta_time_avg_ms(),
23                log.fps_average()
24            );
25            let _ = std::io::stdout().flush();
26        }
27    }
28}
Source

pub fn fps_average(&self) -> f64

fps averaged over the interval since the last call to Timer::log

Examples found in repository?
examples/fps/main.rs (line 23)
5fn main() {
6    let args: Vec<String> = env::args().collect();
7    let fps = args
8        .get(1)
9        .and_then(|arg| arg.parse().ok())
10        .unwrap_or(420.69);
11
12    let mut timer = Timer::default()
13        .log_interval(Duration::from_millis(100))
14        .high_precision(true)
15        .fps(fps);
16
17    loop {
18        let _dt = timer.frame();
19        if let Some(log) = timer.log() {
20            print!(
21                "{:>15.6}ms ({:>10.3}fps)      \r",
22                log.delta_time_avg_ms(),
23                log.fps_average()
24            );
25            let _ = std::io::stdout().flush();
26        }
27    }
28}

Trait Implementations§

Source§

impl Debug for Log

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Log

§

impl RefUnwindSafe for Log

§

impl Send for Log

§

impl Sync for Log

§

impl Unpin for Log

§

impl UnwindSafe for Log

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.