Improving Performance with Baseline Profiles | by Ben Weiss | Android Developers | Aug, 2022

Improving Performance with Baseline Profiles, A swift rundown of Baseline Profiles

Improving Performance with Baseline Profiles

In this MAD Expertise write-up on bettering efficiency with Baseline Profiles you’ll find out what Baseline Profiles are and how they can be made use of to strengthen app startup and velocity up runtime.

Baseline Profiles support your application to begin and operate speedier by optimizing important code paths forward of time. This permits for a smoother consumer practical experience.

We have seen considerable app launch and runtime improvements many thanks to making use of Baseline Profiles. You can examine on how Google Maps improved their app launch time by up to 40 % just after introducing Baseline Profiles.

On a side notice, we’re keen to solution your issues on Android Performance in our are living Q&A session on Sept 1st. Make confident to go away a comment in this article, on YouTube or working with #MADPerfQA on Twitter so we can get back to you.

You can observe the accompanying movie to this article right here.

Enhancing Effectiveness with Baseline Profiles

Baseline Profiles are a record of classes and procedures that are ahead of time compiled and mounted with your app. This usually means that your code does not want to be interpreted using the just-in-time (JIT) compiler when the app is made use of. This interprets into startup time improvements, lessened jank, and total enhanced runtime general performance for end buyers.

Baseline Profiles can be produced for programs and bundled with the application that’s currently being transported to users. But also libraries can build their have Baseline Profile and ship it with their AAR. The Baseline Profiles from libraries will be merged into an application’s Baseline Profile and then compiled into a solitary file, which is delivered with the application alone.

To velocity up the development approach, Baseline Profiles are not installed for debug builds but only for release builds. So, to see the performance gains of your profile, always confirm it versus a release establish.

Generally verify effectiveness gains in a release establish.

Jetpack Compose is a preferred example for a library that delivers a Baseline Profile. By providing library buyers this profile, Jetpack Compose can lower the effects of getting an unbundled UI toolkit for release builds of an app.

The Macrobenchmark library arrives with a rule to create Baseline Profiles for you. By using UIAutomator you can generate the profile generator by means of an app’s critical user journeys. The API phone calls built in the app will be captured and built-in into the Baseline Profile which the Macrobenchmark library results in.

The least viable set up for a baseline profile generator seems like this.
Below code will produce a baseline profile for you and you can put into practice clickThroughUserJourney() to guidebook the generator to much more elaborate eventualities.

course BaselineProfileGenerator 
val baselineProfileRule = BaselineProfileRule()

enjoyable startup() = baselineProfileRule.collectBaselineProfile(
packageName = “com.illustration.application”

You can see a how a trivial Baseline Profile generator is established up in our sample application on GitHub. And the Now in Android sample application has a additional elaborate Baseline Profile set up.

To learn extra about the Macrobenchmark library and how to set up a benchmark, examine the previous article in this series, or observe the online video.

Inspecting Effectiveness

The codelab to generate a Baseline Profile guides you as a result of the latest very best practices to get commenced and leaves you with a 1st Baseline Profile.

The future write-up is all about monitoring application general performance.

Go and test out our enhanced developer documentation, which we have been updating with MAD steering.

To get much more in depth code, check out the samples on GitHub or take the Macrobenchmarking Codelab or Baseline Profiles Codelab for palms-on advice as a result of the subjects.

Make guaranteed to question your thoughts in the online video feedback or on Twitter, working with #MADPerfQA to get solutions straight from the Engineers functioning on Android General performance in our Q&A session on Sept 1st

And check out the comprehensive MAD Competencies collection on general performance debugging to get an edge on how you can inspect what is heading on in your code.

Overall performance Debugging