zoukankan      html  css  js  c++  java
  • Performance(CPU/MEM) Monitoring with /proc in Android

    /proc/stat

    记录了CPU使用的数据,比如CPU在用户态、nice和内核态的时间,其单位是USER_HZ or Jiffies (1/100 seconds)

    > adb shell cat /proc/stat

    cpu  18485 385 17818 1731820 10138 10 244 0 0 0
    cpu0 16059 283 16775 847113 8982 10 243 0 0 0
    intr 742034 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 335460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4502 271 0 12616 0 0 0 0 0 0 0 0 0 0 0 0 0 0 474 4 0 0 0 0 0 0 0 0 0 13652 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 27 0 13225 0 0 0 0 4039 0 1094 0 1655 0 0 0 0 1 956 0 0 0 0 0 0 0 0 0 42918 99426 11516 0 84206 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 835 0 0 0 0 0 2312 0 6132 0 0 0 530 0 0 0 0 0 0 0 47097 0 0 0 0 0 0 0 0 0 0 1
    0 0 0 0 0 0 0 0 0 0 0 0 0 5836 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 27609 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 9132 0 0 0 2685 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7048 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 269 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6412 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    ctxt 2751051
    btime 1330237572
    processes 2407
    procs_running 1
    procs_blocked 0
    softirq 641387 215 343387 12 699 10 10 61002 2682 804 232566

    /proc/%d/stat

    记录了某个进程的CPU和Memory的信息。其中Memory的单位是

    >adb shell cat /proc/2416/stat
    2416 (test.simplechat) S 131 131 0 0 -1 4194624 1080685 0 138 0 17038 3175 0 0 20 0 32 0 927564 257974272[VSS, byte] 17879[RSS, page,should be 4k] 4294967295 1 1 0 0 0 0 4612 4096 34024 4294967295 0 0 17 0 0 0 0 0 0 51

    /proc/%d/task

    记录在某个进程下面各个线程的id, 每个线程会创建一个文件夹,在下面可以看到更多关于这个线程的信息。

    >adb shell ls /proc/2416/task
    2416
    2417
    2418
    2419
    2420
    2421
    2422
    2423
    2424
    2425
    2426

    /proc/%d/statm
    提供某个进城的memory信息,其单位是page

    >adb shell cat /proc/2416/statm
    47304 9139 4779 1 0 5643 0

    VSS and RSS

    VSS indicates how much virtual memory is associated with the process, Resident Set Size indicates how many physical pages are associated with the process.


    VSS is generally meaningless on Android.  If I memory-map a 1MB file, VSS grows by 1MB, but I haven't used any resources (other than entries in a virtual mapping table).


    RSS is partially meaningless on Android, because it doesn't identify pages shared between multiple processes.  If process A has an RSS of 2MB, and process B has an RSS of 2MB, it's possible that there are 4MB of physical pages occupied.  It's also possible that there are only 2MB of physical pages occupied.

    PSS and USS

    USS is the count of pages that are unique to that process.  PSS is RSS reduced by a percentage according to how many processes share the physical pages.  For example, if there are three processes sharing the same 6MB region, each process will adjust their RSS count by 6MB, but only add 2MB to their PSS.

    Ref:

    1. http://www.linuxhowtos.org/System/procstat.htm

    2. top.c

    3. http://homepages.cwi.nl/~aeb/linux/man2html/man5/proc.5.html

    4. procrank

    5. http://elinux.org/Android_Memory_Usage

    6. http://hi.baidu.com/donghaozheng/blog/item/235da701ab70f60a1c95832e.html

  • 相关阅读:
    OpenCV IplImage FlyCapture2 Image Conversion 两种图像类的相互转化
    [FlyCapture2] Bumblebee XB3 Save Images to Three AVI Files (Left, Center and Right) 大黄蜂立体相机保存捕获的视频到左中右三个不同的文件
    Links About Point Grey FlyCapture2 and Triclops
    Android方法数methods超过65536
    Android studio 3.1.1 找不到DDMS
    Android Error:Could not run build action using Gradle installation
    Android Studio maven-metadata.xml 卡着不动原因和解决方法
    Android 4.4及以后将内容布局延伸到状态栏
    java 通过文件后缀名查找文件
    GreenDao 数据库升级 连接多个DB文件 或者指定不同的model&dao目录
  • 原文地址:https://www.cnblogs.com/whyandinside/p/2368852.html
Copyright © 2011-2022 走看看