print_real_time_stats() function
Function to print the CPU usage of tasks over a given duration. This function will measure and print the CPU usage of tasks over a specified number of ticks (i.e. real time stats). This is implemented by simply calling uxTaskGetSystemState() twice separated by a delay, then calculating the differences of task run times before and after the delay.
Arguments
xTicksToWait
Period of stats measurement
Return value
- ESP_OK Success - ESP_ERR_NO_MEM Insufficient memory to allocated internal arrays - ESP_ERR_INVALID_SIZE Insufficient array size for uxTaskGetSystemState. Trying increasing ARRAY_SIZE_OFFSET - ESP_ERR_INVALID_STATE Delay duration too short
Notes
If any tasks are added or removed during the delay, the stats of those tasks will not be printed. This function should be called from a high priority task to minimize inaccuracies with delays. When running in dual core mode, each core will correspond to 50% of the run time.