“I bought and installed their app, and I liked it, but I had to get rid of it because it was eating up my battery.”
Are your customers telling their friends that about your app? It may run perfectly, and your code may be exquisite, but if it consumes power inefficiently, that could be a show-stopper kind of bug that normal debugging tools aren’t set up to detect.
That’s why we built the Trepn™ Profiler and made it available on the Snapdragon™ Mobile Development Platform (MDP). Trepn is a profiling tool designed to measure your app’s effects on power, data and CPU. It helps you see how your programming choices affect power consumption so you can write power-aware, network-aware apps.
This post is a brief summary of how you can profile your own apps using Trepn.
How Trepn Profiler works
Trepn uses a series of sensors embedded in the MDP to monitor power consumption along different “rails,” like each of the CPU cores, the digital core and total power in the device (see diagram).
The Trepn Profiler lives and runs on the MDP itself, close to the hardware. Once your app is installed on the MDP, you launch the Trepn Profiler, start profiling, and then select the app to profile. Trepn collects five seconds of data as a baseline, and then you perform the test or use case of interest. In both real-time and playback modes, Trepn shows you a graph and statistics on power consumption (see diagram), and you can save the data to an SD card for review later.
Application states in Trepn Profiler
You can also correlate particular blocks of your code to Trepn’s output and trace power consumption spikes to the offending code using application states. These statements:
Intent stateUpdate = new Intent("com.quicinc.Trepn.UpdateAppState");
let you broadcast Android Intents that Trepn captures and logs as application states. You can track events such as changes in audio volume or network socket opens, comparing them against the baseline. Trepn determines the per-app CPU cycles using the Linux-layer statistics for each process currently running.
Trepn captures and displays dozens of different statistics for power, CPU and network activity, which you can select in Preferences. Consult the appendix to the Trepn Profiler User Guide for a detailed list.
Keep in mind that you can only get Trepn Profiler with the Snapdragon MDP, because the hardware blocks that contain the embedded power sensors are available only on the MDP, not on other Snapdragon-powered devices. This is one more reason that the MDP is an ideal tool for your app development and testing.
- Watch Chris Spath’s 15-minute presentation from the Uplinq conference, Optimizing Your App for Power on the Device & Over the Network Using Trepn Power Profiler, which includes a hands-on demo
- Have a look at the deep-dive session from the Uplinq conference on the Trepn Profiler, Optimizing Apps for Power & Network Efficiency Using the Snapdragon MDP
- Get more information on Trepn Profiler and the Snapdragon MDP.
If you’ve used the Trepn Profiler to measure your app’s effects on power, data and CPU, I’d be interested to hear your feedback in the comments below.