[HTML payload içeriği buraya]
29.3 C
Jakarta
Monday, May 11, 2026

successfully A/B take a look at energy consumption on your Android app’s options



Posted by Mayank Jain – Product Supervisor, and Yasser Dbeis – Software program Engineer; Android Studio

Android builders have been telling us they’re in search of instruments to assist optimize energy consumption for various gadgets on Android.

The brand new Energy Profiler in Android Studio helps Android builders by displaying energy consumption taking place on gadgets because the app is getting used. Understanding energy consumption throughout Android gadgets may help Android builders establish and repair energy consumption points of their apps. They will run A/B exams to check the ability consumption of various algorithms, options and even totally different variations of their app.

The new Power Profiler in Android Studio

The brand new Energy Profiler in Android Studio

Apps that are optimized for decrease energy consumption result in an improved battery and thermal efficiency of the machine, which suggests an improved consumer expertise on Android.

This energy consumption knowledge is made accessible via the On System Energy Monitor (ODPM) on Pixel 6+ gadgets, segmented by every sub-system known as “Energy Rails”. See Profileable energy rails for a listing of supported sub-systems.

The Energy Profiler may help app builders detect issues in a number of areas:

    • Detecting unoptimized code that’s utilizing extra energy than needed.
    • Discovering background duties which can be inflicting pointless CPU utilization.
    • Figuring out wakelocks which can be retaining the machine awake when they don’t seem to be wanted.

As soon as an influence consumption concern has been recognized, the Energy Profiler can be utilized when testing totally different hypotheses to grasp why the app might be consuming extreme energy. For instance, if the difficulty is brought on by background duties, the developer can attempt to cease the duties from operating unnecessarily or for longer durations. And if the difficulty is brought on by wakelocks, the developer can attempt to launch the wakelocks when the useful resource shouldn’t be in use or use them extra judiciously. Then examine the ability consumption earlier than/after the change utilizing the Energy Profiler.

On this weblog put up, we showcase a method which makes use of A/B testing to grasp how your app’s energy consumption traits would possibly change with totally different variations of the identical function – and how one can successfully measure them.

An actual-life instance of how the Energy Profiler can be utilized to enhance the battery lifetime of an app.

Let’s assume you’ve gotten an app via which customers should purchase their favourite films.

Sample app to demonstrate A/B testing for measure power consumption

Pattern app to show A/B testing for measure energy consumption 
Video (c) copyright Blender Basis | www.bigbuckbunny.org

As your app turns into in style and is utilized by extra customers, you notice that a top quality 4K video takes very lengthy to load each time the app is began. Due to its giant measurement, you need to perceive its impression on energy consumption on the machine.

Initially, this video was in 4K high quality in the very best of intentions, in order to showcase the very best film highlights to your prospects.

This makes you suppose…

    • Do you really want a 4K video banner on the house display screen?
    • Does it make sense to load a 4K video over the community each time your app is run?
    • How will the ability consumption traits of your app change for those who change the 4K video with one thing of decrease high quality (whereas nonetheless preserving the vivid look & really feel of the video)?

This can be a excellent state of affairs to carry out an A/B take a look at for energy consumption

With an A/B take a look at, you possibly can take a look at two barely totally different variations of the video banner function and select the one with the higher energy consumption traits.

Situation A : Run the app with 4K video banner on display screen & measure energy consumption

Situation B : Run the app with decrease decision video banner on display screen & measure energy consumption

A/B Take a look at setup

Let’s take a second and arrange our Android Studio profiler to run this A/B take a look at. We have to begin the app and fasten the CPU profiler to it and set off a system hint (the place the Energy Profiler will probably be proven).

Step 1

Create a customized “Run configuration” by clicking the three dot menu > Edit

Custom run configuration

Customized run configuration

Step 2

Then choose the “Profiling” tab and be certain that “Begin this recording on startup” and CPU Exercise > System Hint is chosen. Then click on “Apply”.

Edit configuration settings

Edit configuration settings

Now merely run the “Profile app startup profiling with low overhead” everytime you need to run this app from begin and fasten the CPU profiler to it.

Notice on precision

The next instance eventualities use your entire app startup for estimating the ability consumption for this weblog’s objective. Nevertheless you need to use extra superior methods to have even increased precision in getting energy readings. Some methods to attempt are:

    • Isolate and measure energy consumption for video playback solely after a faucet occasion on the video participant
    • Use the hint markers API to mark the beginning and cease time for energy measurement timeline – after which solely measure energy consumption inside that marked window

Situation A

On this state of affairs, we run the app with 4K video taking part in and measure energy consumption for the primary 30 seconds. We will optionally additionally run the state of affairs A a number of occasions and common out the readings. As soon as the System hint is proven in Android Studio, choose the 0-30 second time vary from the timeline choice panel and report as a screenshot for evaluating towards state of affairs B

Power consumption in scenario A - playing a 4k video

Energy consumption in state of affairs A – taking part in a 4k video

As you possibly can see, the common energy consumed by WLAN, CPU cores & Reminiscence mixed is about 1,352 mW (milliwatts)

Now let’s examine and distinction how this energy consumption adjustments in Situation B

Situation B

On this state of affairs, we run the app with low high quality video taking part in and measure energy consumption for the primary 30 seconds. As earlier than, we will additionally optionally run state of affairs B a number of occasions and common out the ability consumption readings. Once more, as soon as the System hint is proven in Android Studio, choose the 0-30 second time vary from the timeline choice panel.

Power consumption in scenario B - playing a lower quality video

Energy consumption in state of affairs B – taking part in a decrease high quality video

The full energy consumed by WLAN, CPU Little, CPU Massive and CPU Mid & Reminiscence is about 741 mW (milliwatts)

Conclusion

All else being equal, Situation B (with decrease high quality video) consumed 741 mW energy as in comparison with Situation A (with 4K video) which required 1,352 mW energy.

Situation B (decrease high quality video) took 45% much less energy than Situation A (4K) – whereas the decrease high quality video supplies little to no visible distinction in perceived high quality of the app’s display screen.

Because of this A/B take a look at for energy consumption, you conclude that changing the 4K video with a decrease high quality video on our app’s house display screen not solely reduces energy consumption by 45%, additionally reduces the required community bandwidth and might doubtlessly additionally enhance the thermal efficiency of the gadgets.

In case your app’s enterprise logic nonetheless requires the 4K video to be proven on the app’s display screen, you possibly can discover methods like:

    • Caching the 4K video throughout subsequent runs of the app.
    • Loading video on a consumer faucet.
    • Loading a picture initially and solely load the video after the display screen has absolutely rendered (delayed loading).

The general energy consumption numbers offered within the above A/B take a look at state of affairs might sound small, however it reveals the methods that app builders can use to successfully A/B take a look at energy consumption for his or her app’s options utilizing the Energy Profiler in Android Studio.

Subsequent Steps

The brand new Energy Profiler is out there in Android Studio Hedgehog onwards. To know extra, please head over to the official documentation.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles