cpu检测命令有两种 :
第一种(推荐,android profile采用这种方式):
adb shell top ,如果需要过滤包,可以使用adb shell top |findstr 包名
>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 dumpsys cpuinfo ,如果过滤包名,可以考虑 adb shell dumpsys cpuinfo |grep 包名
区别:
top跟dump cpuinfo的区别在于 top分母是总测CPU jiffies,而dump cpuinfo是是时间,而并非jiffies,也能解释为什么top出来的cpu,大部分时间会比dump cpuinfo小的原因。