Select a language to translate this page!
Powered by Microsoft® Translator
This blog post was authored by Rahul Bagaria, a program manager on the Windows Phone developer tools team.
Smartphones have become an integral part of our lives, and we increasingly rely on them. With our phones we play games, check email, connect with friends, navigate using GPS, or enjoy music and videos. Even as technology has led to advanced hardware designs and more efficient processing over the years, battery life remains a common cause of frustration to users.
As smartphone apps become more immersive and powerful, a huge toll is placed on the phone’s battery. Poorly written apps can zap 30% to 40% of a phone’s battery due to energy inefficient design, which often leads to bad user experience and eventually negative ratings and reviews. However, very few tools are currently available for developers to improve energy efficiency of their apps or even understand the amount of battery power consumed by their applications.
Worry not. The new Windows Phone SDK 8.0 introduces an advanced Power Monitoring tool that can help you build energy-efficient applications. When this tool is used in conjunction with the Simulation Dashboard, it can help you investigate how your app’s battery consumption varies with different networks and real-life network conditions. This tool can allow you to estimate (based on power modeling with a standard 1500mAh battery) the battery charge consumed by your app’s use of CPU, display, network, and other resources, allowing you to fix energy bugs easily.
Before exploring the new Power Monitoring features, let us do a quick recap of Electricity 101 to understand the basic ideas involved in context of Windows Phone. The Power Monitoring tool is easy to use and doesn’t require extensive knowledge, but it’s a good idea to have a basic understanding of these terms:
As Windows Phone developers, you might already be optimizing your apps for performance, memory usage, and bandwidth consumption. It might seem that these optimizations would also lead to efficient battery consumption, but in practice, these are not always correlated. Different design choices might have the same performance, memory usage, and bandwidth consumption, but they can consume significantly different energy.
Taking some pointers from an MSR paper on ‘Empowering Developers to Estimate App Energy Consumption’, let us look at two such scenarios that you might be facing while developing Windows Phone apps and how you can use Power Monitoring to affect battery efficiency.
The amount of battery consumed by apps can differ significantly depending on the colors used in the design as well as different media elements like pictures, animations, and background art. As an example, let’s consider two background images that are the same size, have similar texture detail, and take the same amount of time to download and render.
I created two versions of an app whose only difference was these background images. When I ran each app for 5 seconds, I found that they consume significantly different battery charge:
The absolute values are not of concern, but the comparative difference is significant. In general, darker colors are best in terms of energy efficiency. Just by changing an app’s background, we can increase the battery life (while running that app) significantly (in this case I observed a 144% increase).
When an application uses the network for data transfer, it consumes additional energy. In addition to the active state of the network interfaces, there also exist low power states, tail states, or idle states that consume battery power even when no data is being transferred, which incidentally is a major cause of energy inefficiency in apps:
Let us see a practical example to explore the Power Monitoring feature in more detail. I am using a simple app that downloads 5 images from a wallpaper website and displays each image at 5 second intervals. Currently, the app downloads in bursts and gets a new image from the website when the timer hits 5 seconds. Let’s run this app through the new Application Analysis tool in Visual Studio, which contains our Power Monitoring feature.
We will run the app twice under monitoring (using the Simulation Dashboard and the emulator): the first time on a simulated 3G network, and the second time on a simulated Wi-Fi network. You’ll need to rebuild the app between runs to clear the cache. You’ll be able to see how the app performs with regard to energy efficiency. When I ran the scenario, I observed the following indicative battery consumption metrics in the summary report:
Battery charge consumption (mAh)
Battery remaining (hours)
We can also see detailed graphs of the network transfer and battery charge consumption if we click the Alerts link in the Summary page, which takes us to the graphs section.
App Monitoring Graphs: Network 3G – Download Staggered
App Monitoring Graphs: Network Wi-Fi – Download Staggered
We can clearly see that the 3G cellular network consumes more energy than the Wi-Fi network. This is due to the 3G cellular network’s extended tail states. An important point to note here is that during every download, the network energy consumption (shown in gray) increases to a higher level and continues at a high level while its tail state consumes more energy after the download is complete. This leads to energy waste, which can be limited by batching the image downloads and getting them in one shot rather than five different times.
Let us change the image download method in the app and get all the images during the first time the connection is established. We’ll then display them as required. When I ran this refurbished app under the same network conditions as before, I observed the following reported indicative figures from Power Monitoring:
As you can see, there is a tremendous improvement in the application’s battery consumption (30% in case of 3G and 22% in case of Wi-Fi for the scenarios I ran), and this can readily be seen in the monitoring graphs as well.
App Monitoring Graphs: Network 3G – Download Batched
App Monitoring Graphs: Network Wi-Fi – Download Batched
When using a 3G network, the interface shifted to a lower power state after some time. When using Wi-Fi, the power state was idle and consumed a negligible amount of power after the single batched download.
What we can learn from this scenario is that when an app downloads multiple files at an interval or makes a large number of requests for small amounts of data, the app can ideally download the files in batch all at once (instead of as required) and execute the requests in parallel. It will still use the same bandwidth and provide a similar user experience, but it will save a lot of energy, which would have been spent in tail states that the network interfaces would go to after each download.
Although display and network use are two of the biggest sources of battery consumption for smartphone apps, CPU energy use also plays a major role in many app design decisions. Let us assume that you are developing a weather app and have a choice between two different media elements to indicate weather phenomenon:
The first choice will consume more energy because of displaying lighter shades, and the second choice will consume more energy due to the CPU processing the animation (if it is a CPU-bound animation). This can be a simple decision to make after you run the app under App Monitoring and see the Battery consumption summary, which will give you an overall picture of the total energy consumption.
We looked at a typical photo app when we explored the Simulation Dashboard and Network Monitoring; let’s see if Power Monitoring can help us make the app more energy efficient. (Check out the PhotoSlydr app which was optimized using the steps below.) I ran the app under a simulated 3G Average network and played through a simple scenario of selecting and exploring an album. I also played a slideshow for a few seconds. This is what the Summary Report showed:
The app seems to perform poorly on energy consumption; I might be able to use the app on my device for only about 3.5 hours before draining the battery. The report also has an Alert that takes us to App Monitoring Graphs:
A warning below the graphs displays an Observation Summary: UI is causing high battery use. Consider changing your color scheme to prevent this.
Given what we know about Display power consumption, we realize that a light color scheme is not good for the app’s energy efficiency and we should change it to dark. Making the changes and running the app again offers significant improvement in regard to battery life. It increases to approximately 5.2 hours!
We just saw a few sample scenarios where you can benefit from using Power Monitoring and build great energy efficient apps. There are various other use cases. Paying attention to a few common guidelines when developing Windows Phone apps can help you optimize your apps for efficient battery consumption and get rave reviews from users!
Isn't battery usage by the display something that varies from device to device? OLED, for example, has no backlight, so it consumes power to light up the screen. LCD, on the other hand, always has the backlight on and consumes power to block the light to create black. So an OLED will consume more power with a brighter image, but an LCD will consume more with a darker image.
How good also, though I also like the quality of LCD screen.
Http://www.yepi6.org | http://www.yepi8.org
@doubledeej: Yes, battery usage by display do vary from device to device. However, LCDs consume battery charge largely depending only on the level of screen brightness and as a developer not under your control. On the other hand, AMOLED displays have battery charge consumption that depends on the RGB color being displayed on the screen which you can directly optimize.
We have found that an averaged AMOLED model provides a good approximate prediction for both AMOLED and LCD cases and that is the one we are using in the SDK. Please note that the tool gives an indicative battery charge consumption and absolute values should not be of concern.
how to run Power Monitoring ?
Power usage over time is interesting but not necessarily accurate. Power usage on most phones drops more rapidly the first 20% than the next 20% and so on (measuring SOC would be more accurate but harder to do).http://www.bankinfoonline.com/
Lets begin to think about new features of windows phone at mobileupdate24.blogspot.com/.../the-most-expected-upcoming-features-of_27.html
The main problem is the low time battery ..
Someone know the best smartephone for this ?