Skip to content

Commit

Permalink
Comment out temporary code
Browse files Browse the repository at this point in the history
  • Loading branch information
benditorok committed Dec 5, 2024
1 parent 77384d9 commit 0680fb9
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions examples/src/aim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,30 @@ async fn main() -> anyhow::Result<()> {
ui.label(format!("Frame time: {:.2} ms", dt.as_secs_f32() * 1000.0));
ui.label(format!("FPS: {:.0}", 1.0 / dt.as_secs_f32()));

// TEMP: Average frame time and FPS
unsafe {
static mut FRAME_TIMES: Vec<f32> = Vec::new();

let current_time = dt.as_secs_f32() * 1000.0;
FRAME_TIMES.push(current_time);

// Keep only frames from the last second
while FRAME_TIMES.len() > 0 && FRAME_TIMES[0] < current_time - 1000.0 {
FRAME_TIMES.remove(0);
}

let avg_frame_time =
FRAME_TIMES.iter().sum::<f32>() / FRAME_TIMES.len() as f32;
let avg_fps = 1000.0 / avg_frame_time;

ui.label(format!("Avg frame time: {:.2} ms", avg_frame_time));
ui.label(format!("Avg FPS: {:.0}", avg_fps));

// Reset stats
if ui.button("Reset stats").clicked() {
FRAME_TIMES.clear();
}
}
// // TEMP: Average frame time and FPS
// unsafe {
// static mut FRAME_TIMES: Vec<f32> = Vec::new();

// let current_time = dt.as_secs_f32() * 1000.0;
// FRAME_TIMES.push(current_time);

// // Keep only frames from the last second
// while FRAME_TIMES.len() > 0 && FRAME_TIMES[0] < current_time - 1000.0 {
// FRAME_TIMES.remove(0);
// }

// let avg_frame_time =
// FRAME_TIMES.iter().sum::<f32>() / FRAME_TIMES.len() as f32;
// let avg_fps = 1000.0 / avg_frame_time;

// ui.label(format!("Avg frame time: {:.2} ms", avg_frame_time));
// ui.label(format!("Avg FPS: {:.0}", avg_fps));

// // Reset stats
// if ui.button("Reset stats").clicked() {
// FRAME_TIMES.clear();
// }
// }
}
ui.end_row();
});
Expand Down

0 comments on commit 0680fb9

Please sign in to comment.