Android查看CPU使用情况
使用adb shell dumpsys cpuinfo 可查看Android应用的cpu使用情况:
Load: 3.28 / 4.35 / 2.52
CPU usage from 30393ms to 18654ms ago (2024-05-08 21:39:52.052 to 2024-05-08 21:40:03.790):
106% 1700/system_server: 70% user + 36% kernel / faults: 95816 minor 11 major
49% 3563/com.bbk.launcher2: 41% user + 7.6% kernel / faults: 118398 minor 48 major
17% 5538/com.android.notes: 16% user + 1.8% kernel / faults: 23199 minor
17% 2886/com.android.systemui: 14% user + 3.1% kernel / faults: 14962 minor
15% 5766/com.google.android.gms: 12% user + 2.8% kernel / faults: 13048 minor 3 major
13% 3485/com.android.phone: 9% user + 4.4% kernel / faults: 9280 minor 1 major
10% 1091/surfaceflinger: 7.4% user + 2.8% kernel / faults: 93 minor
10% 3133/com.android.settings:SettingsExProvider: 8.6% user + 1.6% kernel / faults: 13202 minor
8.9% 5626/com.google.android.gms.persistent: 7.3% user + 1.5% kernel / faults: 5173 minor
8.3% 3842/com.vivo.globalsearch: 7.3% user + 0.9% kernel / faults: 12961 minor
7.1% 2911/com.vivo.abe: 5% user + 2% kernel / faults: 7645 minor 7 major
7.1% 4255/com.vivo.gamecube:daemon: 6.8% user + 0.3% kernel / faults: 1660 minor
6.9% 574/ueventd: 6.2% user + 0.6% kernel / faults: 18 minor
6.9% 597/logd: 2.4% user + 4.4% kernel / faults: 1290 minor
4.9% 1446/mobile_log_d: 2.4% user + 2.4% kernel / faults: 716 minor
3% 771/kworker/u17:5-mhi_w: 0% user + 3% kernel
2.8% 761/statsd: 1% user + 1.8% kernel / faults: 40 minor
......
+0% 6621/com.baidu.map.location: 0% user + 0% kernel
+0% 6645/com.vivo.favorite:nail: 0% user + 0% kernel
+0% 6717/com.vivo.weather.provider: 0% user + 0% kernel
+0% 6746/com.google.process.gapps: 0% user + 0% kernel
+0% 6782/com.android.printspooler: 0% user + 0% kernel
+0% 6826/com.mobiletools.systemhelper: 0% user + 0% kernel
+0% 6995/com.qualcomm.telephony: 0% user + 0% kernel
+0% 7060/android.process.media: 0% user + 0% kernel
+0% 7194/com.android.vending: 0% user + 0% kernel
+0% 7293/com.android.localtransport: 0% user + 0% kernel
+0% 7319/com.vivo.favorite: 0% user + 0% kernel
+0% 7336/com.iqoo.secure:remote: 0% user + 0% kernel
+0% 7472/com.android.externalstorage: 0% user + 0% kernel
+0% 8004/com.vivo.car.networking: 0% user + 0% kernel
+0% 8049/com.vivo.findphone: 0% user + 0% kernel
67% TOTAL: 45% user + 19% kernel + 0.1% iowait + 1.6% irq + 0.6% softirq
结果说明(只了解了部分字段含义)
第一行:
Load: 3.28 / 4.35 / 2.52
表示最近1分钟、5分钟、15分钟的cpu平均负载;
如果 1分钟load值 < 15分钟load值,说明cpu使用率在下降;
如果 1分钟load值 >= 15分钟load值,说明cpu使用率还在上升,需要注意;
如果是单核cpu,最大处理能力为1,一直大于1时需要排查;
如果是双核cpu,最大处理能力为 cpu核心数=2,一直大于2时需要排查;
第二行:
CPU usage from 30393ms to 18654ms ago (2024-05-08 21:39:52.052 to 2024-05-08 21:40:03.790):
指统计时间段
第三行及之后:
106% 1700/system_server: 70% user + 36% kernel / faults: 95816 minor 11 major
106% ——该进程的cpu使用占比
1700/system_server ——应用进程id、包名
70% user + 36% kernel —— 该进程用户、内核 使用的cpu使用占比
最后一行:
67% TOTAL: 45% user + 19% kernel + 0.1% iowait + 1.6% irq + 0.6% softirq
CPU使用情况总计
精彩的人生需要浪漫、无畏和勇气。