Measuring estimated CPU utilization

plajjd
Posts: 54
Joined: Thu Jul 05, 2018 11:47 pm

Measuring estimated CPU utilization

Postby plajjd » Wed Aug 08, 2018 10:52 pm

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!

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: Measuring estimated CPU utilization

Postby urbanze » Wed Aug 08, 2018 11:03 pm

Yes, you can use FreeRTOS statitcs, just enable this option in menuconfig-component-freertos and its free use.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Measuring estimated CPU utilization

Postby fly135 » Wed Aug 08, 2018 11:10 pm

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

plajjd
Posts: 54
Joined: Thu Jul 05, 2018 11:47 pm

Re: Measuring estimated CPU utilization

Postby plajjd » Thu Aug 09, 2018 3:00 pm

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!

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Measuring estimated CPU utilization

Postby fly135 » Thu Aug 09, 2018 3:23 pm

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

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 102 guests