Is there a tool that would allow you to measure the battery used in milli amps or milli watts by your application on an iPhone or an Android. Specifically, I want to run my application with a few test cases, then be able to see how much more battery was used by me running the application versus the phone sitting idle. I was able to find a tool for Android here from Intel, however, it does not offer a similar solution for IOS. Preferably, I would like to use the same tool for both IOS and Android..
PowerTutor is an application for Google phones that displays the power consumed by major system components such as CPU, network interface, display, and GPS receiver and different applications. The application allows software developers to see the impact of design changes on power efficiency. Application users can also use it to determine how their actions are impacting battery life. PowerTutor uses a power consumption model built by direct measurements during careful control of device power management states. This model generally provides power consumption estimates within 5% of actual values. A configurable display for power consumption history is provided. It also provides users with a text-file based output containing detailed results. You can use PowerTutor to monitor the power consumption of any application.
http://ziyang.eecs.umich.edu/projects/powertutor/
Related
I'm developing android app using OpenCL for CPU-GPU parallel computing. I want to measure CPU-GPU each power consumption or total power consumption in app execution. But I can't find proper measurement method.
The Android Developer site provides you with all you need :
https://developer.android.com/training/monitoring-device-state/index.html
You can :
1.Monitor the Battery Level and Charging State
2.Determine and Monitor the Docking State and Type
I have used ODROID-XU to measure energy consumption in CPU and GPU.
They provide power sensors for the 2 CPUs, GPU, and memory.
I have made a few scripts for collecting and analysing such data. Available here:
https://github.com/luiscruz/greenbenchmark
This is a good approach if you need reliable measurements.
On the contrary, software-based approaches only provide an estimation which might not be accurate.
I want to monitor battery usage on a very granular level. Like what is the battery usage of each individual activity, or even more granular detail like what is the battery usage in running a for loop of my app. Is there any android app or developer tool using which I can do that on an app whose code I already have?
No, because your phone is not capable of measuring "battery usage on a very granular level".
The closest you will get is with a Qualcomm MDP device and their battery measurement software. Even then, the battery usage by process is somewhat guesswork, as the contributors to power drain (CPU, screen, radios, etc.) are shared by all running processes that use them. A few other off-the-shelf devices may also work as well, though I suspect that the battery measurement software will work a lot better on an MDP, as it has dedicated hardware for this stuff.
Getting finer-grained detail than that will be impractical. At best, with a lot of testing, you might be able to draw some conclusions comparing two algorithms, but for most such algorithms, you would probably be just as well off measuring how much CPU time they took, and extrapolate battery usage from there.
I'm guessing that you want to use algorithms that are very efficient to minimize power usage by your program. If this is true, you are going about it the wrong way. The power consumption by computational algorithms is trivial compared to (a) the usage of external peripherals such as blue tooth and wireless, and (b) preventing the processor from dropping into an idle state. To maximize the power efficiency of your app, you want it to be idle (meaning asleep, not spinning) for as long as possible.
I need to get statistics about the battery in milliAmpere.
I've already found how to get the battery percentage and voltage but not the current.
There are applications like this that can do it but i wonder how.
Thank you
I believe the only way to get the current is via the logcat. The system will occasionally post it to there so you'll need to go back find the last update for it.
There is no way of measuring current drawn from within the system - this or any other app can only estimate it based on timing information and voltage discharge that the system reports. You are not likely to have anything accurate based on just that though - to have more accurate information you need an accurate device power model.
There is a nice article by the Android framework guys about how the power model is built (also applies to the built-in battery power monitor).
TL;DR
Measurement can be accomplished using a bench power supply or using specialized battery-monitoring tools (such as Monsoon Solution Inc.’s Power Monitor and Power Tool software).
Need to control what components of the device are active (screen on/off/brightness level, cellular/wifi/bluetooth radio, gps, CPU, etc.)
Based on those you build an energy profile similar to the example at the bottom of the page
There are also typical values in the table in the document. Warning: these are highly hardware-dependent
You can then apply the model by monitoring the state of the device and activities of applications (screen state, foreground/background, CPU/network use by an app, etc.)
This is a lot of hard work (sorry about that :) ), but there isn't another good way - it is actually an active research problem...
How to check the power consumption in each applications in Android?
At least the power consumption should be relative when compared with different applications and these applications might be using any of the services like WIFI,GPS,LCD,wakelock, etc.
Are there any APIs in android regarding the same in order to measure the power consumption for the applications using the above resources?
There is a research paper called “Accurate Online Power Estimation and Automatic Battery Behavior Based Power Model Generation for Smartphones”. For this paper the researchers developed a tool called PowerTutor, the sources of which you can find here. It should be mentioned that your device has to be rooted to use this application.
First, the powertutor from Google Play is out of date. I've checked the source code of it, and find that the power estimation model is for some old mobile models. The value from power tutor is way smaller than the actual power consumption.
Therefore, I would recommend you to use Battery Historian which is developed by google used to estimate battery consumption of each App. But it's written in Python/Go. It will illustrate the hardware invocation in a html file. And you can find battery consumption of each App in a corresponding text file.
Battery Historian Example
Check out Powertutor. It is in my experience the best application out there to measure application wise power consumption. It is not 100% accurate but is good enough for estimations.
You cannot programatically check the battery consumption for each application.
Instead you can check the overall consumption like this:
energyLeftInmAh = device battery capacity in mAh * battery level in % * 0.01;
E.g
Nexus 5,
battery capacity: 2300 mAh
mBatteryManager = (BatteryManager)MainActivity.this.getSystemService(Context.BATTERY_SERVICE);
int level = mBatteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
double mAh = (2300 * level * 0.01);
(disclaimer: I co-founded the company which built the below mentioned product)
Try Little Eye from Little Eye Labs, that does exactly this. One can track an individual app's power and get the breakdown by CPU/display & Wifi (the upcoming version will support GPS and 3G). It also goes beyond power and tracks data, memory and CPU consumption of an individual app. Note its a desktop tool that you need to download and install from here.
Hope this helps.
One easy guide to see which is consuming how much battery from ICS onwards is to check Settings->Battery. Here it shows the % consumed by the app. Other ways could be to physically monitor battery drop by using the app intensively, for e.g. battery may be 80% before u start using the app. Then you try for 30 minutes and then check battery % again.
I'm looking for a list of all the components and their power drainage on an up-to-date smart phone.
Accelerometer, gyroscope, magnetometer, etc.
Display
WiFi
Bluetooth
GPS
CPU
Camera
Microphone
etc.
Preferably in mA so it can be easily compared to the battery's capacity (usually specified in mAh).
The Sensor's power is actually available via the SDK and can also easily figured out for most devices on AndroidFragmentation. However what I'm looking for is comparable data for the other hardware components to consider their efficency.
Bonus: Will a request for less frequent updates of a Sensor decrease energy consumption of the Sensor, as it returns only one value for getPower()?
There are a couple of detailed studies that I am able to find on this.
A study from the USENIX meeting in 2010 which studies various components of a smartphone (except the camera)
Another study from the Hotmobile mobile computing workshop 2013 that has more information on cameras and displays.
Reference 1 especially seems a great starting point.
I'm looking for a list of all the components and their power drainage on an up-to-date smart phone.
That is impossible to answer.
First, different devices will use different varieties of these components, with different power characteristics.
Second, many, if not most, of those components will have no published power statistics, or the specific components themselves may not be knowable without a complete teardown of a device.
Will a request for less frequent updates of a Sensor decrease energy consumption of the Sensor, as it returns only one value for getPower()?
That will depend on the sensor. Some sensors are effectively always "on" (e.g., ambient light sensor), courtesy of the OS, in which case the only incremental power drain for your use of that sensor will be in passing that sensor data to your process. Other sensors might not be regularly used by the OS, meaning that your request for events from that sensor might turn it "on", resulting in power drain from the sensor itself in addition to supplying you with that data.
It would be truly wonderful if all Android devices were instrumented in the way the Qualcomm MDP is, so that we could get fine-grained power detail for our apps and their usage of various components.
There was a Google I/O session on this very subject a few years ago; you can see the video here and slides pdf here.
I know it's against the rules to plug your own startup, but what you're asking sounds exactly like what we're working on.
There's an Android performance monitoring tool called "Little Eye Labs". It shows real-time power consumption of an App as it runs on a phone. It currently only supports CPU, Display, GPS, Wifi and 3G, but you'll be able to get the instantaneous power consumed (in mW) by these components.
/end of plug
Note that there's no real way to get this information directly from a device, so the best you can do is model the phone, gather device resource consumption, and model power usage.
Display is the most power consuming part of the smartphones; accounting for up to 60% of total battery life (Can draw power up to 2W). There is a book called Green IT and its Applications; you can read it online in Google books.
On any modern Android, go to Settings > Battery (sometimes Settings > About > Battery). You should see a graph of power drain over time, as well as how much was used by what component.
Although consumption varies a lot based on usage patterns, in my experience the top consumers are display, radio, and CPU. I have not seen sensors rank high in energy use on any of my devices, in the absence of bugs. The link provided by Yusuf X places game sensors above CPU.
For more information about optimizing battery use on Android, see Reducing the battery impact of apps that downloads content over a smartphone radio and Optimizing Battery Life.
There is an app called PowerTutor that it does some battery consumption measurements for every phone component and for every process. The code is open so you can pick up some ideas from there. Note that this app was optimized for Google's phone, especially for the Nexus One.