Page 1 of 1
Measuring estimated CPU utilization
Posted: Wed Aug 08, 2018 10:52 pm
by plajjd
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!
Re: Measuring estimated CPU utilization
Posted: Wed Aug 08, 2018 11:03 pm
by urbanze
Yes, you can use FreeRTOS statitcs, just enable this option in menuconfig-component-freertos and its free use.
Re: Measuring estimated CPU utilization
Posted: Wed Aug 08, 2018 11:10 pm
by fly135
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?
Not too hard...
Code: Select all
vTaskGetRunTimeStats(pmem);
printf(pmem);
It seems to only give relative infomation. But it's enough to give you an idea of how much each task is taking relative to the others including the idle tasks.
John A
Re: Measuring estimated CPU utilization
Posted: Thu Aug 09, 2018 3:00 pm
by plajjd
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!
Re: Measuring estimated CPU utilization
Posted: Thu Aug 09, 2018 3:23 pm
by fly135
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