本文介绍了将“顶部"描述为Android中的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个小的Android应用程序以显示当前的总CPU使用率,例如Windows Task Manager中的Performance选项卡.我使用"top -m 1 -n 1 -d 1"来获取CPU使用率,但我不太了解"top"的结果.

I'm making a small Android application to show current total CPU usage like tab Performance in Windows Task Manager.I use "top -m 1 -n 1 -d 1" to get CPU usage, but i do not really understand the result of "top".

结果如下:

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使用率= ???如何计算CPU总使用率?

CPU usage = ???How can i calculated total CPU usage?

推荐答案

该问题的可接受答案不正确.输出的第二行是在该分组中启动的线程/进程的数量.上面的CPU使用率是20%.其中5%来自用户应用,而15%来自系统应用.您有73个空闲线程,14个系统线程和5个用户线程(根据第二行).

The accepted answer for this question is incorrect. The second line of the output is the number of threads/processes that are launched in that grouping. Your CPU usage is 20% in the above. 5% of that is from user apps and 15% from system apps. You have 73 idle threads, 14 system threads, and 5 user threads (according to the second line).

例如,这是Droid的当前顶部快照.

for instance, here is a current top snapshot 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

根据接受的答案,当这实际上只是线程数时,我将拥有310%的CPU使用率.我可以肯定我实际上只使用11%的CPU,而前3个进程使用的是总CPU的9%.

According to the accepted answer, I would have 310% CPU usage, when this is actually just the number of threads. I am pretty sure I am actually using only 11% of the CPU, where the top 3 processes are using 9% of that total.

这篇关于将“顶部"描述为Android中的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 14:00