3 unstable releases
0.2.0 | Jun 11, 2024 |
---|---|
0.1.1 | Jun 11, 2024 |
0.1.0 | Jun 10, 2024 |
88 downloads per month
12KB
149 lines
FPS Timer
Fps timer implementation with very accurate timings.
Example
use std::{env, io::Write, time::Duration};
use fps_timer::Timer;
fn main() {
let args: Vec<String> = env::args().collect();
let fps = args
.get(1)
.and_then(|arg| arg.parse().ok())
.unwrap_or(420.69);
let mut timer = Timer::default()
.log_interval(Duration::from_millis(100))
.high_precision(true)
.fps(fps);
loop {
let _dt = timer.frame();
if let Some(log) = timer.log() {
print!(
"{:>15.6}ms ({:>10.3}fps) \r",
log.delta_time_avg_ms(),
log.fps_average()
);
let _ = std::io::stdout().flush();
}
}
}