CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::core::CpuStats Class Reference

On-demand aggregate CPU-load read-out from FreeRTOS run-time stats. More...

#include <CpuStats.h>

Static Public Member Functions

static bool sample (uint64_t &idleUs, uint64_t &wallUs)
 Snapshot cumulative idle CPU time and the wall-clock reference.
static uint8_t loadOverWindow (uint32_t windowMs=250)
 Measure aggregate CPU load over a blocking window.

Detailed Description

On-demand aggregate CPU-load read-out from FreeRTOS run-time stats.

Requires CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS. Load is derived from the idle-task run-time counters versus wall-clock time across all cores. Nothing is sampled in the background; a caller measures only when it asks.

Definition at line 14 of file CpuStats.h.

Member Function Documentation

◆ loadOverWindow()

uint8_t cdc::core::CpuStats::loadOverWindow ( uint32_t windowMs = 250)
static

Measure aggregate CPU load over a blocking window.

Parameters
windowMsMeasurement window in milliseconds.
Returns
CPU load across all cores as 0..100 percent.

Definition at line 40 of file CpuStats.cpp.

References sample().

Referenced by cdc::ui::buildHardwareInfoText(), and cdc::serial::cmdCpu().

◆ sample()

bool cdc::core::CpuStats::sample ( uint64_t & idleUs,
uint64_t & wallUs )
static

Snapshot cumulative idle CPU time and the wall-clock reference.

Parameters
idleUsOut: summed run-time of every core's idle task, in run-time counter units (microseconds with the esp_timer source).
wallUsOut: current wall clock from esp_timer, in microseconds.
Returns
true on success, false if run-time stats are unavailable.

Definition at line 12 of file CpuStats.cpp.

References cdc::core::psramAlloc().

Referenced by host_cpu_load(), and loadOverWindow().


The documentation for this class was generated from the following files: