Skip to main content

par_term/app/
debug_state.rs

1use std::time::{Duration, Instant};
2
3/// State related to debug metrics and FPS overlay
4pub struct DebugState {
5    pub frame_times: Vec<Duration>, // Last 60 frame times for FPS calculation
6    pub cell_gen_time: Duration,    // Time spent generating cells last frame
7    pub render_time: Duration,      // Time spent rendering last frame
8    pub cache_hit: bool,            // Whether last frame used cached cells
9    pub last_frame_start: Option<Instant>, // Start time of last frame
10    pub show_fps_overlay: bool,     // Whether to show FPS overlay (toggle with F3)
11    pub fps_value: f64,             // Current FPS value for overlay display
12}
13
14impl Default for DebugState {
15    fn default() -> Self {
16        Self::new()
17    }
18}
19
20impl DebugState {
21    pub fn new() -> Self {
22        Self {
23            frame_times: Vec::with_capacity(60),
24            cell_gen_time: Duration::ZERO,
25            render_time: Duration::ZERO,
26            cache_hit: false,
27            last_frame_start: None,
28            show_fps_overlay: false,
29            fps_value: 0.0,
30        }
31    }
32}