# Implementation Plan: Performance Dashboard (performance_dashboard_20260306) > **Reference:** [Spec](./spec.md) | [Architecture Guide](../../../docs/guide_architecture.md) ## Phase 1: Historical Data Storage Focus: Add history buffer to PerformanceMonitor - [ ] Task 1.1: Initialize MMA Environment - [ ] Task 1.2: Add history deque to PerformanceMonitor - WHERE: `src/performance_monitor.py` `PerformanceMonitor.__init__` - WHAT: Rolling window of metrics - HOW: ```python from collections import deque self._history: deque = deque(maxlen=100) ``` - [ ] Task 1.3: Store metrics each frame - WHERE: `src/performance_monitor.py` `end_frame()` - WHAT: Append current metrics to history - HOW: ```python def end_frame(self) -> None: # ... existing code ... self._history.append({ "fps": self._fps, "frame_time_ms": self._frame_time_ms, "cpu_percent": self._cpu_percent, "input_lag_ms": self._input_lag_ms }) ``` - [ ] Task 1.4: Add get_history method - WHERE: `src/performance_monitor.py` - HOW: ```python def get_history(self) -> list[dict]: return list(self._history) ``` ## Phase 2: CPU Graph Focus: Render CPU usage over time - [ ] Task 2.1: Extract CPU values from history - WHERE: `src/gui_2.py` diagnostics panel - WHAT: Get CPU% array for plotting - HOW: ```python history = self.perf_monitor.get_history() cpu_values = [h["cpu_percent"] for h in history] ``` - [ ] Task 2.2: Render line graph - WHERE: `src/gui_2.py` - WHAT: imgui.plot_lines for CPU - HOW: ```python if imgui.collapsing_header("CPU Usage"): imgui.plot_lines("##cpu", cpu_values, scale_min=0, scale_max=100) imgui.text(f"Current: {cpu_values[-1]:.1f}%" if cpu_values else "N/A") ``` ## Phase 3: Frame Time Histogram Focus: Show frame time distribution - [ ] Task 3.1: Bucket frame times - WHERE: `src/gui_2.py` - WHAT: Categorize into 0-16ms, 16-33ms, 33+ms - HOW: ```python buckets = [0, 0, 0] # <16ms, 16-33ms, 33+ms for h in history: ft = h["frame_time_ms"] if ft < 16: buckets[0] += 1 elif ft < 33: buckets[1] += 1 else: buckets[2] += 1 ``` - [ ] Task 3.2: Render histogram - WHERE: `src/gui_2.py` - HOW: ```python imgui.plot_histogram("##frametime", buckets) imgui.text("<16ms: {} 16-33ms: {} >33ms: {}".format(*buckets)) ``` ## Phase 4: Testing - [ ] Task 4.1: Write unit tests - [ ] Task 4.2: Conductor - Phase Verification