Android 通过adb shell命令查看内存,CPU,启动时间,电量等信息

1、  查看内存信息

1)查看所有内存信息

命令:

dumpsys meminfo

 

例:

C:\Users\laiyu>adb shell

shell@android:/ $ dumpsys meminfo

dumpsys meminfo

Applications Memory Usage (kB):

Uptime: 80066272 Realtime: 226459939

 

Total PSS by process:

    90058 kB: com.tencent.mobileqq (pid 16731)

    57416 kB: system (pid 651)

    52052 kB: com.miui.home (pid 1121)

Total PSS by OOM adjustment:

   223177 kB: Persistent

               57416 kB: system (pid 651)

               50036 kB: com.android.deskclock (pid 1096)

…………

   252678 kB: Foreground

               90058 kB: com.tencent.mobileqq (pid 16731)

…………

    50944 kB: Visible

               20318 kB: com.miui.miwallpaper (pid 974)

…………

    90855 kB: Perceptible

               36448 kB: com.google.android.inputmethod.pinyin (pid 987)

…………

    39654 kB: A Services

               23320 kB: com.tencent.android.qqdownloader (pid 14080)

…………

Total PSS by category:

   454627 kB: Dalvik

   137206 kB: Unknown

   100835 kB: .so mmap

    62670 kB: .dex mmap

    54208 kB: Other dev

    30258 kB: Other mmap

     8527 kB: .apk mmap

     4752 kB: .ttf mmap

     2216 kB: Ashmem

       60 kB: Cursor

       21 kB: .jar mmap

        0 kB: Native

 

Total PSS: 855380 kB

      KSM: 0 kB saved from shared 0 kB

           0 kB unshared; 0 kB volatile

 


---------------------------------------------------------------------------------------------


2、  查看CPU信息

1linux系统的top命令

 

例子:

C:\Users\laiyu>adb shell

shell@android:/ $ top -d 1 | busybox grep "com.tencent.mobileqq" > /mnt/sdcard/p

erformance.txt

encent.mobileqq" > /mnt/sdcard/performance.txt                                <</span>

^C

C:\Users\laiyu>


注:直接使用grep可能报错,提示找不到命令,这时如果busybox中有grep命令,可以如上,busybox grep


查看导出文件,如下,红色框选部分即为cpu利用率



方法2:通过dummpsys cpuinfo命令

命令:adb shell dumpsys cpuinfo

或者分成两部走(参考 查看电量信息)

adb shell,然后dumpsys cpuinfo

 

例:

C:\Users\laiyu>adb shell dumpsys cpuinfo | find "com.tencent.mobileqq"

  0.1% 16731/com.tencent.mobileqq: 0.1% user + 0% kernel / faults: 8 minor

  0% 16753/com.tencent.mobileqq:MSF: 0% user + 0% kernel

  0% 19646/com.tencent.mobileqq:qzone: 0% user + 0% kernel

 

3、  查看应用启动时间

命令:

adb logcat -c && adb logcat -f /mnt/sdcard/up.txt -s tag

 

选项说明

-c   清屏

-f     指定运行结果输出文件,默认输出到标准设备(一般是显示器

-s   设置默认的过滤级别为Silent

tag  仅显示priority/tag

更多信息烦请参考 adb logcat -help

 

例:

先启动app,然后执行如下命令

C:\Users\laiyu>adb logcat -c && adb logcat -f /mnt/sdcard/up.txt -s ActivityMana

ger

^C

C:\Users\laiyu>

 

查看输出文件:



I/ActivityManager

注:查找Dispalyed字眼,如上图,可看到应用(com.tentcent.mobileqq)启动时间(total +4s410ms),启动页停留展示时间(+835ms)


4、  查看电量信息

命令:

dumpsys battery

 

例:

shell@android:/ $ dumpsys battery

dumpsys battery

Current Battery Service state:

  AC powered: false

  USB powered: true

  status: 5

  health: 2

  present: true

  level: 100

  scale: 100

  voltage:4211

  temperature: 297

  technology: Li-poly

shell@android:/ $

 

展开阅读全文

没有更多推荐了,返回首页