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.
How to get "CPU load" and "Memory Usage"
Re: How to get "CPU load" and "Memory Usage"
Your interpretation of what you see, perhaps?snahmad75 wrote:Any thing wrong here.
I use that routine. It seems to provide useful info as long as the uptime is not too long.
John A
Re: How to get "CPU load" and "Memory Usage"
Just FYI....
http://esp32.info/docs/esp_idf/html/d3/ ... Stats.htmlNOTE 1: This function will disable interrupts for its duration. It is not intended for normal application runtime use but as a debug aid.
Re: How to get "CPU load" and "Memory Usage"
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?
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?
Re: How to get "CPU load" and "Memory Usage"
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%?
e.g.
IDLE0 3975459304 241%
IDLE1 819548835 49%
tiT 95644729 5%
Tmr Svc 49 <1%
....
How can IDLE0 reach 241%?
Re: How to get "CPU load" and "Memory Usage"
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%?
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.It seems to provide useful info as long as the uptime is not too long.
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
Re: How to get "CPU load" and "Memory Usage"
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
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
-
- Posts: 168
- Joined: Sun May 22, 2022 2:42 pm
Re: How to get "CPU load" and "Memory Usage"
A cumulated view since reboot is just not cutting it. This is a big oversight. Please support me @ https://github.com/espressif/esp-idf/issues/11302
-
- Posts: 94
- Joined: Tue Sep 07, 2021 12:07 pm
Re: How to get "CPU load" and "Memory Usage"
I've been using this to get a smoothed idle count for each CPU. The reported number is typically around 2,000 - 20,000 or higher when everything is good. Under 1000 means there is not much idle time left.
Call the two report_get_idleN() functions from somewhere...
This is for ESP-IDF; probably something similar could work on the Arduino IDE.
Code: Select all
// Register a callback to be called from the specified core’s idle hook.
// The callback should return true if it should be called by the idle hook
// once per interrupt (or FreeRTOS tick), and return false if it should be
// called repeatedly as fast as possible by the idle hook.
#define idleUsageTask_stack 1024 // reports.c
#define idleUsageTask_core OTHERCORE
#define idleUsageTask_wait_ms 100
#define idleUsageTask_priority 3 /*configMAX_PRIORITIES is 5*/
static int s_idle0;
static int s_idle0report;
static bool idle0() { s_idle0 += 1; return false;}
static int s_idle1;
static int s_idle1report;
static bool idle1() { s_idle1 += 1; return false;}
int report_get_idle0() { return s_idle0report; }
int report_get_idle1() { return s_idle1report; }
static void idleUsageTask(void *arg)
{
while(1)
{
s_idle0report = s_idle0;
s_idle0 /= 2;
s_idle1report = s_idle1;
s_idle1 /= 2;
vTaskDelay(idleUsageTask_wait_ms/portTICK_PERIOD_MS);
}
}
void report_init_cpu_usage()
{
esp_register_freertos_idle_hook_for_cpu(idle0, 0/*cpuid*/);
esp_register_freertos_idle_hook_for_cpu(idle1, 1/*cpuid*/);
xTaskCreatePinnedToCore(idleUsageTask, "idleUsageTask", idleUsageTask_stack, NULL/*arg*/, idleUsageTask_priority, NULL/*handle*/, idleUsageTask_core);
}
This is for ESP-IDF; probably something similar could work on the Arduino IDE.
Craige
Who is online
Users browsing this forum: No registered users and 95 guests