Skip to content

feschber/fps-timer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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();
        }
    }
}

About

a very accurate fps timer written in rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages