Does anyone suggestions on measuring CPU utilization on the ESP32? I read through an existing post on this topic, but it did not seem to have an answer.
I don't need exact utilization - just a good estimate.
In the past I've been able to do this by instrumenting the Idle Task with a counter and doing some timed experiments. However, I haven't used FreeRTOS like this before.
I also see that FreeRTOS has a function to report statistics - but apparently this is not (easily?) used in the ESP-IDF environment?
Any suggestions will be appreciated!
Measuring estimated CPU utilization
Re: Measuring estimated CPU utilization
Yes, you can use FreeRTOS statitcs, just enable this option in menuconfig-component-freertos and its free use.
Re: Measuring estimated CPU utilization
Not too hard...plajjd wrote:I also see that FreeRTOS has a function to report statistics - but apparently this is not (easily?) used in the ESP-IDF environment?
Code: Select all
vTaskGetRunTimeStats(pmem);
printf(pmem);
John A
Re: Measuring estimated CPU utilization
Thank you!
I have a question about the output, tho. Here is what I see:
main .73499010..27
IDLE .34030062..12
IDLE .131589919..49
Tmr Svc .51..<1
esp_timer .24066650..9
ipc1 .2076..<1
ipc0 .1561..<1
Two questions:
1. Does this mean that 'main' is taking 27% of the time?
2. Why are there two IDLE tasks? I thought maybe this was from both CPUs, but the numbers add up to 100, so I am assuming this is all for a single CPU?
Thanks again!
I have a question about the output, tho. Here is what I see:
main .73499010..27
IDLE .34030062..12
IDLE .131589919..49
Tmr Svc .51..<1
esp_timer .24066650..9
ipc1 .2076..<1
ipc0 .1561..<1
Two questions:
1. Does this mean that 'main' is taking 27% of the time?
2. Why are there two IDLE tasks? I thought maybe this was from both CPUs, but the numbers add up to 100, so I am assuming this is all for a single CPU?
Thanks again!
Re: Measuring estimated CPU utilization
It's for 2 cores, hence two idle tasks. It appears they designed it to be 50% for each core. The percentage numbers don't always seem to add up right, but that's what they appear to be. In your example, main is taking up 2x27 = 54% of a single core.
John A
John A
Who is online
Users browsing this forum: Baidu [Spider], Bing [Bot] and 85 guests