Skip to main content

ass_renderer/debug/player/
report.rs

1use crate::Frame;
2
3#[cfg(not(feature = "nostd"))]
4use std::time::Duration;
5
6#[cfg(feature = "nostd")]
7use alloc::vec::Vec;
8
9pub struct PlayerFrame {
10    pub frame: Frame,
11    pub timestamp_ms: u32,
12    pub render_time: Duration,
13    pub frame_number: u32,
14}
15
16#[derive(Debug)]
17pub struct TestReport {
18    pub test_points: Vec<TestPoint>,
19    pub total_render_time: Duration,
20    pub frames_with_content: usize,
21    pub frames_empty: usize,
22    pub average_render_time_ms: f64,
23}
24
25impl TestReport {
26    pub fn print_summary(&self) {
27        println!("\n╔════════════════════════════════════════╗");
28        println!("║         Test Report Summary            ║");
29        println!("╚════════════════════════════════════════╝");
30
31        println!("\n📈 Overall Statistics:");
32        let test_points_len = self.test_points.len();
33        println!("  • Test points: {test_points_len}");
34        println!(
35            "  • Frames with content: {} ({:.1}%)",
36            self.frames_with_content,
37            (self.frames_with_content as f32 / self.test_points.len() as f32) * 100.0
38        );
39        println!(
40            "  • Empty frames: {} ({:.1}%)",
41            self.frames_empty,
42            (self.frames_empty as f32 / self.test_points.len() as f32) * 100.0
43        );
44        println!(
45            "  • Average render time: {:.2}ms",
46            self.average_render_time_ms
47        );
48        println!(
49            "  • Total render time: {:.2}ms",
50            self.total_render_time.as_secs_f64() * 1000.0
51        );
52
53        println!("\n📊 Performance Distribution:");
54        let mut fast = 0;
55        let mut normal = 0;
56        let mut slow = 0;
57
58        for point in &self.test_points {
59            let ms = point.render_time.as_secs_f64() * 1000.0;
60            if ms < 5.0 {
61                fast += 1;
62            } else if ms < 15.0 {
63                normal += 1;
64            } else {
65                slow += 1;
66            }
67        }
68
69        println!("  • Fast (<5ms): {fast}");
70        println!("  • Normal (5-15ms): {normal}");
71        println!("  • Slow (>15ms): {slow}");
72
73        println!("\n🔍 Individual Test Points:");
74        for point in &self.test_points {
75            println!(
76                "  • {:6}ms: {:.2}ms render | {}",
77                point.timestamp_ms,
78                point.render_time.as_secs_f64() * 1000.0,
79                if point.has_visible_content {
80                    "✓ visible"
81                } else {
82                    "✗ empty"
83                }
84            );
85        }
86
87        println!("\n═══════════════════════════════════════");
88    }
89}
90
91#[derive(Debug)]
92pub struct TestPoint {
93    pub timestamp_ms: u32,
94    pub render_time: Duration,
95    pub has_visible_content: bool,
96}