Implement the low-risk performance improvements in Cleanmeter before changing monitoring behaviour or the sidecar protocol.
Mars’s optimisation plan separates low-risk, behaviour-gated, and protocol/native changes. Adnan requested two scheduled parts. This part covers the source’s low-risk phase; Part 2 retains the two higher-risk phases separately.
Filter PresentMon rows by the text before the first comma before splitting matching rows, retaining ParseData tests. Guard debug-only diagnostic strings and dictionaries with logger.IsEnabled(LogLevel.Debug). Replace the float/string round trip with float.IsNaN(v) ? 0 : v. Remove the every-second GC.Collect, enable GCConserveMemory and compare working set. Reset memoryStream.SetLength(0) between writes, make JSON options static, and precompute progress strings. Emit sensor events to the overlay and to Settings only when visible, pushing the last snapshot immediately when Settings opens. For monitor layout, use the quick version: poll for the first 60 seconds and re-arm the short polling burst on resize, DPI change or visibilitychange; retain that burst as the fallback. Replace repeated sensor find/toLowerCase searches with an identifier Map and exact /presentmon/frametime lookup, keeping fuzzy matching as fallback.
Keep Rust’s HardwareMonitorData shape, the 1000ms polling default, selected sensors and visible update rates unchanged. Run HardwareMonitor.Tests and vitest after each phase; compare five-minute FPS and 1% lows recordings in the same game scene on old/new builds within normal noise; verify every picker sensor, hotkeys, sleep/resume, display changes and borderless games. Record before/after results and pass the verified baseline into Part 2. A later move to Windows display/power/session events was a future step in the source, not a prerequisite for this quick version.
The low-risk overhead is removed without changing readings, update cadence or visible behaviour, with per-phase regression evidence recorded.