Add perf console (render fps, flush cost, CPU idle, heap) for the display work; record idle baseline
Firmware / build (push) Successful in 4m8s

This commit is contained in:
2026-09-27 16:43:53 +02:00
parent 43ca6b96ec
commit d3e499efed
8 changed files with 277 additions and 4 deletions
+46
View File
@@ -0,0 +1,46 @@
/*
* Performance Monitor
*
* Measures what the display pipeline actually does, so display experiments
* (bounce buffers, draw-buffer size, XIP from PSRAM - wiki open question #13)
* can be compared with numbers instead of impressions:
*
* - render frames/s and ms per frame (LVGL's monitor_cb: render + flush)
* - time spent copying pixels into the PSRAM framebuffer (flush_cb)
* - LVGL task idle % (lv_timer_get_idle)
* - CPU idle % per core (FreeRTOS run-time stats)
* - internal heap, largest block, PSRAM free
*
* Console:
* perf one line for the last window
* perf on [sec] print a PERF, line every <sec> s (default 1) - use while
* provoking symptoms (Wi-Fi scan, tuning save, OTA)
* perf off
*
* PERF line (CSV, greppable like CANRAW):
* PERF,<ts_ms>,<fps>,<avg_ms>,<max_ms>,<kpx/frame>,<flush_ms/s>,
* <lvgl_idle%>,<idle0%>,<idle1%>,<int_free>,<int_largest>,<psram_free>
*/
#pragma once
#include <Arduino.h>
namespace PerfMon {
/** Call once in setup(), before the LVGL port starts. */
void init();
/** Hook for lv_disp_drv_t::monitor_cb - one rendered frame (ms, pixels). */
void onFrame(uint32_t time_ms, uint32_t px);
/** Hook for the flush callback - one pixel copy into the framebuffer. */
void onFlush(uint32_t time_us, uint32_t px);
/** Console line beginning with "perf". */
bool handleCommand(const char* line);
/** Periodic reporting. Call from loop(). */
void tick();
} // namespace PerfMon