How to get higher precision of “CPU%” than that from TOP command?

前端 未结 4 685
走了就别回头了
走了就别回头了 2021-02-02 02:08

When I use TOP command, I could get the following info:

shell@android:/ $ top -n 1                                                     

User 31%, System 10%, IO         


        
4条回答
  •  误落风尘
    2021-02-02 02:33

    Got this information from another thread:

    3) Getting CPU info

    ~$ adb shell dumpsys cpuinfo

    Output:

    Load: 0.08 / 0.4 / 0.64 CPU usage from 42816ms to 34683ms ago: system_server: 1% = 1% user + 0% kernel / faults: 16 minor kdebuglog.sh: 0% = 0% user + 0% kernel / faults: 160 minor tiwlan_wq: 0% = 0% user + 0% kernel usb_mass_storag: 0% = 0% user + 0% kernel pvr_workqueue: 0% = 0% user + 0% kernel +sleep: 0% = 0% user + 0% kernel +sleep: 0% = 0% user + 0% kernel TOTAL: 6% = 1% user + 3% kernel + 0% irq

    EDIT:

    You can also try this command: echo $(adb shell ps | grep com.android.phone | awk '{ system("adb shell cat /proc/" $2 "/stat");}' | awk '{print $14+$15;}')

    Also:

    using top : This will show you the cpu stats top -b -n 1 |grep ^Cpu

    using ps: This will show you the % cpu usage for each process. ps -eo pcpu,pid,user,args | sort -r -k1 | less

    EDIT2:

    In realtion to your comments and the bounty description (How can I guess which thread eats the battery?) I found an interesting page:

    http://ziyang.eecs.umich.edu/projects/powertutor/

    As stated there:

    You can use PowerTutor to monitor the power consumption of any application.

    Try this for an instance and see if it meets your requirements.

    FINAL EDIT:

    Check out the Systrace documentation on the developer.android.com site:

    http://developer.android.com/tools/debugging/systrace.html http://developer.android.com/tools/help/systrace.html

    I'm sorry if you already tried that, but that's one concrete method to measure the performance.

提交回复
热议问题