Approximate reasonably CPU load per core?

mharizanov
Posts: 5
Joined: Tue Dec 15, 2015 8:26 am

Approximate reasonably CPU load per core?

Postby mharizanov » Thu Nov 21, 2019 11:08 am

Folks,
Is there an "official" way to read the approximate CPU load e.g. how much time is spent in IDLE vs other tasks? I'd ideally need this per core, tips on how to achieve that would be appreciated.
Thanks

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

Re: Approximate reasonably CPU load per core?

Postby urbanze » Thu Nov 21, 2019 1:42 pm

mharizanov wrote:
Thu Nov 21, 2019 11:08 am
Folks,
Is there an "official" way to read the approximate CPU load e.g. how much time is spent in IDLE vs other tasks? I'd ideally need this per core, tips on how to achieve that would be appreciated.
Thanks
With RTOS stats, you can see task usage of all tasks of both cpus (including IDLEs)

https://www.freertos.org/rtos-run-time-stats.html

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: Approximate reasonably CPU load per core?

Postby PeterR » Thu Nov 21, 2019 1:55 pm

Note: The above link gives you a total count. You may also wish to see load over 0.25 seconds. You would have to write that code yourself but its fairly easy to populate an array with task name and last run count from which to perform the delta.
I found that the returned task list would change the order of tasks so I am afraid you will have to hunt your entry if you want to see deltas.
& I also believe that IDF CAN should be fixed.

mharizanov
Posts: 5
Joined: Tue Dec 15, 2015 8:26 am

Re: Approximate reasonably CPU load per core?

Postby mharizanov » Thu Nov 21, 2019 2:22 pm

Thanks for the pointers. Looks like with some fiddling, it will work. I'll update the thread.

mharizanov
Posts: 5
Joined: Tue Dec 15, 2015 8:26 am

Re: Approximate reasonably CPU load per core?

Postby mharizanov » Thu Nov 21, 2019 6:02 pm

Got it working. Had to enable "Component config > FreeRTOS > Enable FreeRTOS to collect run time stats " in menuconfig (IDF 3.3)

Gives me output like this:

Code: Select all

main					886790		<1%
IDLE1				146272698	90%
IDLE0				151160911	93%
buzzer_task			153997		<1%
tiT					439292		<1%
mqtt_task				2849535		1%
lvgl_task				14420182		8%
Tmr Svc				76			<1%
rfm69				73008		<1%
ipc0					2973947		1%
esp_timer				70375		<1%
wifi					2703508		1%
ipc1					251647		<1%
eventTask				11000		<1%
gpio_task				807			<1%


So CPU load per core is 100%-IDLE[0,1]

Thanks!

mharizanov
Posts: 5
Joined: Tue Dec 15, 2015 8:26 am

Re: Approximate reasonably CPU load per core?

Postby mharizanov » Fri Nov 22, 2019 12:13 pm

PeterR wrote:
Thu Nov 21, 2019 1:55 pm
Note: The above link gives you a total count. You may also wish to see load over 0.25 seconds. You would have to write that code yourself but its fairly easy to populate an array with task name and last run count from which to perform the delta.
I found that the returned task list would change the order of tasks so I am afraid you will have to hunt your entry if you want to see deltas.
Thanks for this, yes, it would make most sense to have "live" data, not accumulated totals since boot. Since my interest is in CPU load, I only care for the delta in IDLE[0,1] task. This makes the code simpler too.

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: Approximate reasonably CPU load per core?

Postby PeterR » Fri Nov 22, 2019 12:57 pm

Cool.
Yes, it works, well sometimes the numbers do not add up to 100% but its good enough.

I have mine also showing load in last 0.25 seconds which helps with bursty activity. Just cannot share.
You will have to go a little native if you want to name std::thread
If you need wrap the constructor and use esp_pthread_set_cfg().
& I also believe that IDF CAN should be fixed.

Who is online

Users browsing this forum: No registered users and 122 guests