Testing Battery Usage Testing Battery Usage android android

Testing Battery Usage


There is a new tool which comes with Android 5.0.

You can run

adb shell dumpsys batterystats > dump.txt

To get the full battery dump of you device. You also can add some options like --unplugged (only output data since last unplugged) or --charged (only output data since last charged). You can also add a packagename to get informations for this package/app only:

adb shell dumpsys batterystats --unplugged your.package.name > dump.txt

The part > dump.txt put everything into a file (maybe just works on Windows, not sure. But you can just leave it away, the dump will be printed right in the console where you can copy it and put it in a file).

This works just if you have a device with Android 5.x.If you have a device with a lower level you can try to use

adb shell bugreport > bugreport.txt

But this file will be very very big. (~8mb+)

After creating this file you can use the Historian Tool of Google

To use it you have to install Python 2.7.9 and run following command

python /path/to/historian.py dump.txt > battery.html

This will create a battery.html file where you can see the data in a more usefull formatting.

Last thing: If you want to reset the stats of the battery dump just call

adb shell dumpsys batterystats --reset

(just works with Android 5.x)


In practice, I believe most apps that have power problems, also have 'CPU' problems. That is, a profile of your application's CPU usage is probably a good approximation of your battery consumption. There are caveats and exceptions if, for example, your app is doing something expensive with the GPU, the wireless network, storage, etc, and that expensive operation isn't taking much CPU time.

Here's an interesting blog about a "Power Tutor" app that provides a more precise measurement on a running system than the built-in battery app:http://gigaom.com/mobile/android-power-consumption-app/. I haven't tried it.

For another level of detail, here is a paper that breaks down which components of a phone suck the most juice (note the paper is from 2010): http://www.usenix.org/event/usenix10/tech/full_papers/Carroll.pdf(Just skip to section 5 to read their results). They say the screen brightness is the biggest culprit.

If the screen brightness is the biggest culprit, be sure to set that to a fixed level if you are measuring your own application's usage.

If you're really interested in measuring power consumption, you can follow their methodology (which invovles opening the phone and physically attaching measuring devices.)


The question that you have asked is a research topic right now.There is some on going research on tracing fine grained power usage i.e tracing power usage on thread or subroutine basis.\

eprof is one tool developed by some university grads.

you can find some papers on this topic here : http://web.ics.purdue.edu/~pathaka/pubs.html

I am working on the same thing, I will surely notify you if anything usable comes for normal users.