show average fps on console
This commit is contained in:
parent
f8148462d2
commit
17de5bcb76
1 changed files with 17 additions and 5 deletions
14
src/main.rs
14
src/main.rs
|
@ -111,6 +111,9 @@ async fn main() {
|
|||
let mut last_tap = std::time::Instant::now();
|
||||
let mut z = 0;
|
||||
|
||||
let mut frame_count = 0;
|
||||
let mut fps_sum_window = std::time::Instant::now();
|
||||
|
||||
let mut active = false;
|
||||
|
||||
for i in 0..5 {
|
||||
|
@ -119,9 +122,18 @@ async fn main() {
|
|||
|
||||
event_loop.run(move |event, elwt| {
|
||||
let tcur = std::time::Instant::now();
|
||||
if (tcur - fps_sum_window).as_millis() > 5000 {
|
||||
let avg_fps = (1000.0 * frame_count as f32) / ((tcur - fps_sum_window).as_millis() as f32);
|
||||
eprintln!("avg fps: {}", avg_fps);
|
||||
fps_sum_window = tcur;
|
||||
frame_count = 0;
|
||||
} else {
|
||||
frame_count += 1;
|
||||
}
|
||||
|
||||
elwt.set_control_flow(ControlFlow::
|
||||
WaitUntil(
|
||||
tcur + Duration::from_millis(100)
|
||||
tcur + Duration::from_millis(25)
|
||||
));
|
||||
inputs.write().unwrap().t = tcur - tbegin;
|
||||
inputs.write().unwrap().transition_time = tcur - transition_begin;
|
||||
|
|
Loading…
Reference in a new issue