hopefully done refining

This commit is contained in:
2026-03-06 16:14:31 -05:00
parent 88e27ae414
commit 1294104f7f
20 changed files with 1736 additions and 734 deletions

View File

@@ -1,26 +1,87 @@
# Implementation Plan: Performance Dashboard (performance_dashboard_20260306)
## Phase 1: Metrics Collection
- [ ] Task: Initialize MMA Environment
- [ ] Task: Verify performance_monitor
- WHERE: src/performance_monitor.py
- WHAT: Check existing metrics
- HOW: Review get_metrics() output
> **Reference:** [Spec](./spec.md) | [Architecture Guide](../../../docs/guide_architecture.md)
## Phase 2: Historical Data
- [ ] Task: Implement metrics history
- WHERE: src/performance_monitor.py
## 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: deque with maxlen
- SAFETY: Memory bounded
- HOW:
```python
from collections import deque
self._history: deque = deque(maxlen=100)
```
## Phase 3: Visualization
- [ ] Task: Render graphs
- WHERE: src/gui_2.py
- WHAT: Line graphs for CPU/RAM/frame time
- HOW: imgui.plot_lines or custom
- SAFETY: 60fps during rendering
- [ ] 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
})
```
## Phase 4: Verification
- [ ] Task: Test graph rendering
- [ ] Task: Conductor - Phase Verification
- [ ] 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