Overhead of gathering CPU load

I have a hardware product based on an ESP32S3 which is using one LED as a heartbeat. I’d like to sync the blink frequency to the CPU load and I wonder whether enabling CONFIG_FREERTOS_GENERATE_RUN_TIME_STAT in production will have a negative impact on my overall performance.

Or is there a more lightweight way to gather the CPU load? I certainly don’t need all the fancy task stats CONFIG_FREERTOS_GENERATE_RUN_TIME_STAT is enabling.

The GATHERING of the Run Time stats is fairly low, basically a reading of the counter for the stats, subtracting the last read value in incrementing the usage of the task being switched out.

Reading ONE tasks stats are fairly quick too, reading that accumulated count.

The slow operation, is the act of trying to retrieve the stats of ALL tasks into a single buffer with coherent timing, which you don’t need, as you can just ask how much time the Idle task has taken compared to total run time (and perhaps make a delta since you last checked).

3 Likes