Testing Battery Usage

AndroidTesting

Android Problem Overview


I want to test how my application effects the battery of a phone/tablet.

Are there any testing tools which will allow me to do so?

For example, I want to test which modules of my application are consuming the most amount of battery, etc.

Android Solutions


Solution 1 - Android

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)

Solution 2 - Android

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.)

Solution 3 - Android

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.

Solution 4 - Android

As of Android 2.3.3 the system has a native Battery monitor.

Settings -> About Phone -> Battery use

Solution 5 - Android

I would say that there is no real tool to test it since it can't be precisely mesured. If you take an iPhone, you will see the battery count go from 40% to 30%, then stay there for a while, go down to 20%, lower to 15%, go up to 25%, Go back to 20% ECT. What you could do is charge your phone for an extended period of time, to make sure it is fully charged, and then use your app until the phone closes, and note the amount of time it took. Now do this with another version and see the result. Basicly you'll have to play the MasterMind game with it if you want to do the less tests as possible. Also, if the change isn't easy to see, it is probably not very important.

Solution 6 - Android

We performed similar testing to know how my application is responsible for battery consumption of Nexus5 phone .

But unfortunately we could not get help from any tool but it was mostly based on manual testing .

We identified some modules in app which were suspected for more battery consumption.

  1. Location awareness module which uses GPS .

  2. Upload module which uses network connection runs a background operation for long time.

  3. Video creation module which also make CPU busy due to background operation. and so on...

Finally after 3-4 round of testing we had some trend in data and we were able to identify the module which was big culprit for battery consumption.

Basically there will be more battery consumption if something is keeping CPU busy more time. So we can think of module which have background operations, network related operations.

As of now I can not find any tool which could tell above testing result in a particular app.

Hope my experience would be beneficial for requirement statement in original question.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionArnab ChakrabortyView Question on Stackoverflow
Solution 1 - AndroidInformatic0reView Answer on Stackoverflow
Solution 2 - AndroidP.T.View Answer on Stackoverflow
Solution 3 - AndroidHarshit SyalView Answer on Stackoverflow
Solution 4 - AndroidhunterpView Answer on Stackoverflow
Solution 5 - Androiduser835875View Answer on Stackoverflow
Solution 6 - AndroidamarnathpatelView Answer on Stackoverflow