feat: implement overlay architecture with IOverlayLayer interface and telemetry overlay
This commit is contained in:
@@ -20,8 +20,8 @@ class TelemetrySnapshot:
|
||||
fps: float
|
||||
frame_time_ms: float # average inter-frame time in ms
|
||||
dropped_frames: int # cumulative dropped frames detected
|
||||
cpu_percent: float # overall CPU usage (0–100)
|
||||
memory_mb: float | None # RSS memory usage in MB (optional)
|
||||
cpu_percent: float # this process CPU usage (0–100, all cores)
|
||||
memory_mb: float | None # process private working set in MB
|
||||
timestamp: float # time.perf_counter() when snapshot was taken
|
||||
|
||||
|
||||
@@ -57,8 +57,9 @@ class TelemetryCollector(QObject):
|
||||
self._fps_window: deque[float] = deque() # timestamps of recent frames
|
||||
self._fps_window_size_s: float = 1.0
|
||||
|
||||
# psutil process reference
|
||||
# psutil process reference — call cpu_percent once to initialise the baseline
|
||||
self._process = psutil.Process()
|
||||
self._process.cpu_percent() # first call always returns 0.0; discard it
|
||||
|
||||
# periodic snapshot timer
|
||||
self._timer = QTimer(self)
|
||||
@@ -138,15 +139,19 @@ class TelemetryCollector(QObject):
|
||||
else:
|
||||
avg_frame_time_ms = 0.0
|
||||
|
||||
# CPU
|
||||
# CPU — this process only, cumulative since last call (non-blocking)
|
||||
try:
|
||||
cpu = psutil.cpu_percent(interval=None)
|
||||
cpu = self._process.cpu_percent()
|
||||
except Exception:
|
||||
cpu = 0.0
|
||||
|
||||
# memory
|
||||
# Memory — private working set (Windows) or RSS (macOS/Linux)
|
||||
# This excludes shared DLLs/frameworks and matches Task Manager "Private"
|
||||
try:
|
||||
mem_mb = self._process.memory_info().rss / (1024 * 1024)
|
||||
mem_info = self._process.memory_info()
|
||||
# wset = Windows Working Set (private); rss on macOS/Linux
|
||||
mem_bytes = getattr(mem_info, "wset", None) or mem_info.rss
|
||||
mem_mb = mem_bytes / (1024 * 1024)
|
||||
except Exception:
|
||||
mem_mb = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user