7

Whether there is any formula ,Api or method for it? I want to test the power consumption of different apps.

The Original Android
  • 6,147
  • 3
  • 26
  • 31
wade Lee
  • 143
  • 1
  • 5
  • 2
    possible duplicate of [per process power consumption in Android](http://stackoverflow.com/questions/6051807/per-process-power-consumption-in-android) – Brian Roach Apr 09 '12 at 13:57

2 Answers2

6

Using adb tools you can view power consumption of each running app

adb shell dumpsys cpuinfo

sample output

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

Using batterystats you can view each app's battery usage and power consumption:

adb shell dumpsys batterystats

To list all available dumpsys tools:

adb shell dumpsys -l

To configure adb tools: http://developer.android.com/guide/developing/tools/adb.html

hb0
  • 3,350
  • 3
  • 30
  • 48
UdayaLakmal
  • 4,035
  • 4
  • 29
  • 40
1

In order to analyse the power consumption, e.g. to estimate the mAh usage, checkout:

To see what's happening live (wakelocks, cpu, sensors, etc.):

enter image description here

To see what happened over time, e.g. this day:

  • [API 21+] the Battery Historian - in combination with Dumpsys Battery. See their github project for instruction. Hovering the battery level chart (black in the screenshot) gives you the discharge rate in mAh when your phone was not charging.

enter image description here

I haven't found out yet if it's possible to see an estimated mAh consumption instead ob abstract "low, mid, high" units in the Profiler. Comment please if you do so. The Historian should be able to do so based on the documentation.

hb0
  • 3,350
  • 3
  • 30
  • 48