pub struct Log { /* private fields */ }
Expand description
A struct holding information about the previous logging interval
Implementations§
Source§impl Log
impl Log
Sourcepub fn delta_time_avg(&self) -> Duration
pub fn delta_time_avg(&self) -> Duration
frame time averaged over the interval since the last call to Timer::log
Sourcepub fn delta_time_avg_ms(&self) -> f64
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}
Sourcepub fn fps_average(&self) -> f64
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§
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> 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