Mobile app optimisation often starts with a feeling that "it's slow", but it should end with a measurable result. Baseline Profiles give a team a way to describe the most important code paths in advance and reduce the work a device does during the first launches and in key journeys.

The Android Calendar case study published on Android Developers is one of the best-documented examples: it has the motivation, the specific journeys, the measurement method and before-and-after numbers. We break it down in detail and add what we see when introducing profiles in our own Android projects.

How Baseline Profiles work

When an Android app launches for the first time after installation, a large share of its code runs in the interpreter or is compiled on the fly by the JIT compiler. That costs CPU time exactly when the user is waiting for the first screen. A Baseline Profile is a list of classes and methods worth compiling in advance. The profile ships with the build, and at install time the system compiles that code ahead of time.

According to Android documentation, Baseline Profiles speed up code execution by about 30% from the first launch, because they skip interpretation and JIT for key journeys. Profiles help not only startup but also smoothness: scrolling, screen transitions, opening complex lists.

There's another mechanism — Cloud Profiles, which Google Play builds automatically from real-world app usage. The Calendar team already had Cloud Profiles, so it's important to understand the difference.

ParameterCloud ProfilesBaseline Profiles
Setupenabled by defaultconfigured by the team
Which journeys are includedchosen automatically from user datachosen by the team
Work best for a user base that islargeany size
When the impact appearsa few days after releaseimmediately
Android versionsAndroid 9 (API 28) and higherAndroid 7 (API 24) and higher

Why the Calendar team needed its own profiles

The main reason was the move to a weekly release cycle. Cloud Profiles reach peak impact only 1–2 days after a version ships, because they rely on aggregated user data. With a weekly cycle, that means people spend a large share of the time on an unoptimised build. Baseline Profiles take effect from the first minute after the update is installed.

The second reason was control. The team wanted to choose the critical user journeys (CUJs) included in the profile themselves. There were two:

  • Opening the app in schedule view — the default view, so it matters for new users and those who don't change settings.
  • Opening the app in month view — according to analytics, many users choose it.

Profiles were generated through an internal wrapper around Jetpack Macrobenchmark: the test launches the app, waits for recurring events and tasks to appear on screen, opens the side drawer and verifies the selected view. Note the detail: the test waits for real content, not just the first frame.

How they measured the result without an A/B test

Baseline Profiles are tightly bound to the APK and are applied before the code runs, so a classic A/B experiment within one version is impossible. The team used controlled releases: only a subset of users received the new version, and its metrics were compared with a group on a version as close as possible to the previous one. Results were aggregated across a wide range of devices:

  • median interactive startup — the most common scenario — dropped from 775 to 644 ms (17%);
  • median cold start — from 1,058 to 901 ms (15%);
  • median warm start — from 453 to 378 ms (17%);
  • the median janky frame rate in schedule and month views decreased by 42–60%.

Overall, the team reports roughly a 20% startup improvement and about a 50% reduction in slow or frozen frames. Even users who open other views benefited: shared processes, such as loading calendar data from the database, were also covered by the profile. The documentation adds a caveat: if Cloud Profiles run in parallel, the difference shrinks slightly during the first week as cloud profiles "catch up".

How to introduce Baseline Profiles: step by step

  1. Pick 2–4 critical journeys. Cold start to the main screen, the most popular transition, the main scrolling list. Use analytics data, not assumptions.
  2. Add the Baseline Profile Gradle plugin and create a module for profile generation. Android Studio has a ready-made template.
  3. Write the generator with BaselineProfileRule. Take the journey to the point where the screen is genuinely populated: wait for a specific UI element. For startup, enable includeInStartupProfile to also get DEX layout optimisation.
  4. Generate the profile on an emulator or physical device and commit the result to the repository.
  5. Measure the effect with Macrobenchmark: compare CompilationMode.None with CompilationMode.Partial using the profile, with StartupTimingMetric and FrameTimingMetric.
  6. Enable R8. R8 rewriting of profiles requires AGP 8.2 or newer; in the Gmail Wear OS case study, that alone added another 20% to startup speed.
  7. Automate regeneration. A profile ages along with the code — regenerate it in CI before every release.
  8. Check field data in Android vitals after a controlled release.

What matters for other teams

  • Profile real key journeys, not a random set of screens.
  • Check results across device classes: the gain is usually largest on weak devices. We explained why this matters in our article on testing on inexpensive devices.
  • Compare controlled groups when an A/B test isn't possible.
  • Combine profiles with Macrobenchmark in the lab and field metrics in Play Console.

Typical mistakes

  • Expecting profiles to fix poor architecture. If Application.onCreate synchronously initialises a dozen SDKs, a profile will only speed up unnecessary work a little.
  • Generating a profile once and forgetting it: a few releases later it covers the wrong code.
  • Measuring on a debug build, where profiles and R8 don't behave as in release.
  • Ending the generation journey at the first frame, so data-loading code never makes it into the profile.
  • Not checking whether the profile actually gets installed: ProfileVerifier in the ProfileInstaller library exists for that.

Checklist

  1. 2–4 critical journeys are defined based on analytics.
  2. The profile generation module works and runs in CI.
  3. There's a Macrobenchmark for startup and smoothness comparing "no profile / with profile".
  4. R8 is enabled and AGP 8.2+ is used.
  5. The effect is confirmed by a controlled release and Android vitals data.
  6. Results are tied to product metrics: abandonment, rating, completion of the key action.

Baseline Profiles work best when the team already knows which path has to be fast. We laid out the general framework of startup metrics in our article on app startup speed. For the business, it's important to link the technical improvement to behaviour: faster startup can reduce abandonment and raise ratings, but that has to be verified with data, not assumed.

Sources: Android Developers: Android Calendar Baseline Profiles case study; Android Developers: Baseline Profiles overview; Android Developers: Benchmark Baseline Profiles with Macrobenchmark; Android Developers: Gmail Wear OS startup case study.