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


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

     

    by:授客 QQ1033553122

     

    1、  查看内存信息

    1)查看所有内存信息

    命令:

    dumpsys meminfo

     

    例:

    C:Userslaiyu>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)

    …………

     

        49659 kB: B Services

                   20085 kB: com.tencent.mobileqq:qzone (pid 19646)

    …………

       148413 kB: Background

                   21457 kB: com.miui.weather2 (pid 14296)

    …………

                    3453 kB: com.miui.providers.datahub (pid 14651)

     

    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)查看某个包的内存信息

    命令:

    dumpsys pkg_name

     

    例:

    shell@android:/ $ dumpsys meminfo com.tencent.mobileqq > /mnt/sdcard/meminfo.txt

    bileqq > /mnt/sdcard/meminfo.txt                                              <</span>

    shell@android:/ $

     

    查看导出结果:

     





    具体输出项含义请搜索网络

     

    2、  查看CPU信息

    1linux系统的top命令

     

    例子:

    C:Userslaiyu>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:Userslaiyu>

     

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

     

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


     

    方法2:通过dummpsys cpuinfo命令

    命令:adb shell dumpsys cpuinfo

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

    adb shell,然后dumpsys cpuinfo

     

    例:

    C:Userslaiyu>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:Userslaiyu>adb logcat -c && adb logcat -f /mnt/sdcard/up.txt -s ActivityMana

    ger

    ^C

    C:Userslaiyu>

     

    查看输出文件:



     

    备注:I/ActivityManager I 代表优先级,ActivityManager代表tag

     

    更清晰图如下




    注:查找
    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:/ $

     

     

  • 相关阅读:
    查找1
    动态规划
    分治
    [LeetCode] 1339. Maximum Product of Splitted Binary Tree
    [LeetCode] 1509. Minimum Difference Between Largest and Smallest Value in Three Moves
    [LeetCode] 233. Number of Digit One
    [LeetCode] 1963. Minimum Number of Swaps to Make the String Balanced
    [LeetCode] 1053. Previous Permutation With One Swap
    [LeetCode] 1962. Remove Stones to Minimize the Total
    [LeetCode] 1961. Check If String Is a Prefix of Array
  • 原文地址:https://www.cnblogs.com/shouke/p/10157881.html
Copyright © 2020-2023  润新知