How to get "CPU load" and "Memory Usage"

snahmad75
Posts: 356
Joined: Wed Jan 24, 2018 6:32 pm

Re: How to get "CPU load" and "Memory Usage"

Postby snahmad75 » Thu Nov 01, 2018 10:04 am

I am not getting good CPU thread/task utlization in percentage.

static char __stats_buffer[1024];
vTaskGetRunTimeStats(__stats_buffer);
printf("%s\n", __stats_buffer);
vTaskList(__stats_buffer);
printf( "%s\n", __stats_buffer);


Any thing wrong here.

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

Re: How to get "CPU load" and "Memory Usage"

Postby fly135 » Thu Nov 01, 2018 5:03 pm

snahmad75 wrote:Any thing wrong here.
Your interpretation of what you see, perhaps?

I use that routine. It seems to provide useful info as long as the uptime is not too long.

John A

username
Posts: 24
Joined: Thu May 03, 2018 1:18 pm

Re: How to get "CPU load" and "Memory Usage"

Postby username » Thu Nov 01, 2018 7:36 pm

Just FYI....
NOTE 1: This function will disable interrupts for its duration. It is not intended for normal application runtime use but as a debug aid.
http://esp32.info/docs/esp_idf/html/d3/ ... Stats.html

snahmad75
Posts: 356
Joined: Wed Jan 24, 2018 6:32 pm

Re: How to get "CPU load" and "Memory Usage"

Postby snahmad75 » Thu Nov 01, 2018 8:35 pm

ok, I see . Thanks for information. yes it was slowly down my application processing. good to know.
I am planning to use visual debugger with visual studio. I hope that do not disable interrupt during get CPU usage.

Is get remaining internal/external ram esp32 function also do same disable interrupt?

axellin
Posts: 24
Joined: Mon Sep 17, 2018 9:09 am

Re: How to get "CPU load" and "Memory Usage"

Postby axellin » Fri Nov 02, 2018 2:02 pm

vTaskGetRunTimeStats output looks wrong (after running for 6 hours):
e.g.
IDLE0 3975459304 241%
IDLE1 819548835 49%
tiT 95644729 5%
Tmr Svc 49 <1%
....

How can IDLE0 reach 241%?

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

Re: How to get "CPU load" and "Memory Usage"

Postby fly135 » Fri Nov 02, 2018 2:33 pm

axellin wrote:vTaskGetRunTimeStats output looks wrong (after running for 6 hours):
e.g.
IDLE0 3975459304 241%
IDLE1 819548835 49%
tiT 95644729 5%
Tmr Svc 49 <1%
....

How can IDLE0 reach 241%?
It seems to provide useful info as long as the uptime is not too long.
I suggest you call either "esp_timer_get_time" or "xTaskGetTickCount()" to get the total system uptime and compare against the runtime numbers for each task. You will get a different result. Not sure why the call to vTaskGetRunTimeStats gets it wrong after running for a while. The source is in the IDF but I never spent the time to investigate.

Also... eventually getting the system uptime will give incorrect results as well. Bottom line... it appears that counters roll over and the times no longer do the trick. I imagine that it could be fixable with a little work. Or you could simply do your profiling closer to the boot time.

John A

snahmad75
Posts: 356
Joined: Wed Jan 24, 2018 6:32 pm

Re: How to get "CPU load" and "Memory Usage"

Postby snahmad75 » Wed Dec 05, 2018 7:58 pm

Hi,

I tried vTaskList. It does not shows cpu usage in percentage.


printf( "Task Name\tStatus\tPrio\tHWM\tTask\tAffinity\n");
char stats_buffer[1024];
vTaskList(stats_buffer);
printf("%s\n", stats_buffer);

Thanks,
Naeem

Who is online

Users browsing this forum: Bing [Bot] and 18 guests