Descrip "top" team in Android

I am making a small Android application to show the current overall CPU usage, such as Tab Performance in Windows Task Manager. I use "top -m 1 -n 1 -d 1" to get the CPU usage, but I really don't understand the result "from above".

Result:

User 5%, system 15%, IOW 0%, IRQ 0% User 5 + Nice 0 + Sys 14 + Idle 73 + IOW 0 + IRQ 0 + SIRQ 0 = 92 PID CPU% S #THR VSS RSS UID Name 213 11% R 1 900K 340K app_16 top 

CPU usage = ??? How can I calculate the total CPU usage?

+8
android memory-management cpu-usage top-command
source share
4 answers

The accepted answer to this question is incorrect. The second line of output is the number of threads / processes that run in this group. CPU usage in this case is 20%. 5% - from user applications and 15% - from system applications. You have 73 idle threads, 14 system threads and 5 user threads (according to the second line).

for example, here is the current top shot for my Droid.

 User 6%, System 5%, IOW 0%, IRQ 0% User 21 + Nice 0 + Sys 16 + Idle 270 + IOW 0 + IRQ 3 + SIRQ 0 = 310 PID CPU% S #THR VSS RSS PCY UID Name 30994 4% S 19 134912K 24140K bg app_24 edu.vu.isis.ammo.spotreport 1021 3% S 57 217400K 58504K fg system system_server 20911 2% R 1 880K 400K fg shell top 1053 0% S 1 0K 0K fg root tiwlan_wq 995 0% S 2 1272K 128K fg compass /system/bin/akmd2 

According to the accepted answer, I will have 310% of CPU usage, when in reality it is just the number of threads. I am sure that in fact I use only 11% of the CPU, where the 3 best processes use 9% of the total.

+10
source share

The actual answer to the question is straightforward - can be calculated from the first line of the top Android exit

 User 5%, system 15%, IOW 0%, IRQ 0% 

Total = total interest = 5 + 15 = 20%

Another answer about the second line is so wrong. The second line actually provides the scheduler time spent in this particular state: user / sys / idle / iow in jiffies (usually 10 ms) between one output of the top and next output from the top - in the case of OP top -d 1 - which prints usage every second - the total number of jiffies per core will be ~ 100 (assuming 10ms per jiffy) - this will look like percentage values.

 User 5 + Nice 0 + Sys 14 + Idle 73 + IOW 0 + IRQ 0 + SIRQ 0 = 92 

While the values ​​will be greater if -d higher or if there is more than one kernel

 User 21 + Nice 0 + Sys 16 + Idle 270 + IOW 0 + IRQ 3 + SIRQ 0 = 310 

This probably doesn't have the -d , so top accepts a default delay of 3 seconds = 300 jiffies.

Refer to the AOSP top sourcecode for a complete logic for calculating each value.

+5
source share

The top command is the linux command. Look here

Thanks Deepak

-2
source share

The processor utilization percentage is set as (100-idle_percentage) , more or less. In your snippet, the Idle percentage is 73, which makes your CPU utilization 27%.

Regarding CPU usage in each process, this will be your second column of the last two rows.

-4
source share

All Articles