Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing Battery Usage

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.

like image 460
Arnab Chakraborty Avatar asked Sep 27 '11 09:09

Arnab Chakraborty


People also ask

How do you measure battery usage?

Multiplying the average or nominal battery voltage times the battery capacity in amp-hours gives you an estimate of how many watt-hours the battery contains.

How can I test my battery performance?

You can check your Android phone's battery status by navigating to Settings > Battery > Battery Usage.

How will you check battery usage in mobile testing?

There is a simple way to analyse and measure battery usage on mobile devices. go for device settings, and tap battery, it displays the battery usage of the each and every app that you have installed.

How do I check battery logs?

Select Search on the taskbar, type Command prompt, press and hold (or right-click) Command prompt, and then select Run as administrator > Yes. At the command prompt, type powercfg /batteryreport, then press Enter. The battery report will be an HTML file that's stored in a folder on your PC.


1 Answers

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)

like image 169
Informatic0re Avatar answered Oct 04 '22 12:10

Informatic0re