6.18 Top
Top指令是Linux下的指令,因此Android上也可以使用Top指令来查看当前进程的CPU信息。在adb shell下,通过输入如下所示的代码来查看Top指令的使用方法。
- shell@mako:/ $ top -h
- Usage: top [ -m max_procs ] [ -n iterations ] [ -d delay ] [ -s sort_column ] [ -t ] [ -h ]
- -m num Maximum number of processes to display.
- -n num Updates to show before exiting.
- -d num Seconds to wait between updates.
- -s col Column to sort by (cpu,vss,rss,thr).
- -t Show threads instead of processes.
- -h Display this help screen.
常用的参数含义如下所示。
- m,最多显示多少个进程。
- n,刷新次数。
- d,刷新间隔时间。
- s,排序方式。
例如下面这些指令。
- shell@mako:/ $ top -n 1 -m 5 -d 1
- User 8%, System 9%, IOW 0%, IRQ 0%
- User 18 + Nice 0 + Sys 19 + Idle 163 + IOW 2 + IRQ 0 + SIRQ 0 = 202
- PID PR CPU% S #THR VSS RSS PCY UID Name
- 2238 0 6% S 94 1961132K 170656K fg u0_a255 com.hujiang.hjclass
- 18631 1 4% R 1 2420K 948K shell top
- 596 0 3% S 94 1616456K 112752K fg system system_server
- 173 1 1% S 17 81224K 10896K fg system /system/bin/surfaceflinger
- 207 1 1% S 8 9560K 680K nobody /system/bin/sensors.qcom
执行指令的含义为,刷新一次(-n 1),前5个进程(-m 5),间隔1秒(-d 1)。显示的信息列表,主要包含两个部分——总览和详细。
