Is there a way to get the average current/power consumption of a particular application in Android? I could only find private API PowerProfile.java and PowerUsageSummary.java which give some information, but I am hitting a dead end, can someone please help?
Is there a way to get the average current/power consumption of a particular application in Android?
No, because applications do not consume current/power. Hardware does. If six applications are using WiFi, it is very difficult to "assign blame" for the WiFi power consumption, for example.
Now, even getting hardware power information is difficult in Android, as there are no public APIs for it, and most hardware is not instrumented particularly well to indicate what is consuming power. The Qualcomm MDP has great instrumentation for this, along with Trepn software to help you collect it, but it is rather expensive.
Related
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...
Is there any way to determine what is using power in an app? From what I have found, the most granular I can get is how much power an app itself is using. I want to know what I can do to make my app more efficient in the most empirical way possible as it is easy to justify a change when there are numbers to back it up.
Is there any way to determine what is using power in an app?
You can buy a Qualcomm MDP device and use Trepn to get fairly accurate and detailed power analysis of your app. However, an MDP is expensive.
Otherwise, there is little you can do, simply because current Android production hardware is not instrumented to try to collect this level of information. Even the Battery screen in Settings is mostly just an educated guess.
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.
I need to perform power measurements for android applications. I tried "powertutor" and it gives the power consumption per every application. Yet, I don't know how accurate its readings are. Does anyone know how accurate it is?
Also, I have used the DDMS to profile the android application. I obtain the processes as memory info about it. Is there a way that i can know the power consumption per process in Android? (some rough estimation?) or is it impossible?
I really need to perform "power" profiling for android applications but I don't know how.
In my academic research for measuring power consumption on Android, we use a power supply hooked up to the phone's battery terminals that outputs the voltage and current to a PC. Measure without the app to get a baseline and then compare against measurements with the app running. It's not extremely accurate, but it's the best way we know how.