fps-timer

Crates.iofps-timer
lib.rsfps-timer
version0.2.0
sourcesrc
created_at2024-06-10 22:45:59.783726
updated_at2024-06-11 16:19:48.029796
descriptionA very accurate fps timer
homepage
repositoryhttps://github.com/feschber/fps-timer
max_upload_size
id1267585
size13,661
Ferdinand Schober (feschber)

documentation

README

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();
        }
    }
}
Commit count: 15

cargo fmt