Crates.io | fps-timer |
lib.rs | fps-timer |
version | 0.2.0 |
source | src |
created_at | 2024-06-10 22:45:59.783726 |
updated_at | 2024-06-11 16:19:48.029796 |
description | A very accurate fps timer |
homepage | |
repository | https://github.com/feschber/fps-timer |
max_upload_size | |
id | 1267585 |
size | 13,661 |
Fps timer implementation with very accurate timings.
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();
}
}
}