adb shell top
一、其中相關參數:
-
>adb shell 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. 刷新間隔時間(默認5秒)
-
-s col Column to sort by (cpu,vss,rss,thr). 按哪列排序
-
-t Show threads instead of processes. 顯示線程信息而不是進程
-
-h Display this help screen. 顯示幫助文檔
比如:
adb shell top -m 5

表示打印出5個進程數,以及相關進程運行所消耗的CPU值百分比。
第一欄相關參數解釋:
-
User 處於用戶態的運行時間,不包含優先值為負進程
-
Nice 優先值為負的進程所占用的CPU時間
-
Sys 處於核心態的運行時間
-
Idle 除IO等待時間以外的其它等待時間
-
IOW IO等待時間
-
IRQ 硬中斷時間
-
SIRQ 軟中斷時間PID 進程id
第二欄相關參數解釋:
-
PID 進程id
-
PR 優先級
-
CPU% 當前瞬時CPU占用率
-
S 進程狀態:D=不可中斷的睡眠狀態, R=運行, S=睡眠, T=跟蹤/停止, Z=僵屍進程
-
#THR 程序當前所用的線程數
-
VSS Virtual Set Size 虛擬耗用內存(包含共享庫占用的內存)
-
RSS Resident Set Size 實際使用物理內存(包含共享庫占用的內存)
-
PCY 調度策略優先級,SP_BACKGROUND/SP_FOREGROUND
-
UID 進程所有者的用戶id
-
Name 進程的名稱
二、命令使用
- adb shell top -m xx 查看XX個進程數
- adb shell top -n XX 刷新XX次
- adb shell top -d XX 刷新頻率
- ……
三、打印出來的數據保存到本地
adb shell top -m 5 > d:\cpu.txt 表示打印的5個進程的數據保存到本地D盤的cpu.txt文件中
四、指定查看某個應用的數據
例如: 監測一次微博的CPU占用情況:adb shell top -n 1 | grep com.sina.weibo
10秒刷新一次顯示CPU占用情況:adb shell top -d 10 | grep com.sina.weibo
實時監測微博的CPU占用情況:adb shell top |grep com.sina.weibo
