如何计算android app的耗电量?

时间:2012-04-09 13:54:05

标签: android performance

是否有任何配方,Api或方法? 我想测试不同应用的功耗。

1 个答案:

答案 0 :(得分:5)

使用adb工具,您可以查看每个正在运行的应用的耗电量

adb shell dumpsys cpuinfo

示例输出

Load: 1.12 / 1.07 / 1.01
CPU usage from 11344ms to 1613ms ago:
  10% 122/system_server: 5.8% user + 4.5% kernel / faults: 989 minor
  0% 233/com.htc.android.wallpaper: 0% user + 0% kernel / faults: 910 minor
  0.8% 271/com.htc.launcher: 0.8% user + 0% kernel / faults: 832 minor
  0% 40/panel_on/0: 0% user + 0% kernel
  0% 8/suspend: 0% user + 0% kernel
  0% 54/synaptics_wq: 0% user + 0% kernel
  0.2% 57/w1_bus_master1: 0% user + 0.2% kernel
  0% 253/com.android.phone: 0% user + 0% kernel / faults: 3 minor
  0% 13/kondemand/0: 0% user + 0% kernel
  0% 56/curcial_wq: 0% user + 0% kernel
  0% 2879/com.htc.bg: 0% user + 0% kernel / faults: 8 minor
  0% 2904/dhd_dpc: 0% user + 0% kernel
  0% 2906/com.google.android.apps.maps:NetworkLocationService: 0% user + 0% kern

使用batterystats,您可以查看每个应用的电池使用情况和耗电量:

adb shell dumpsys batterystats

列出所有可用的dumpsys工具:

adb shell dumpsys -l

配置adb工具: http://developer.android.com/guide/developing/tools/adb.html