Use a baseline profile
Stay organized with collections
Save and categorize content based on your preferences.
Baseline Profiles improve code execution speed by about 30% from the first
launch by avoiding interpretation and just-in-time (JIT) compilation steps for
included code paths. By shipping a Baseline Profile in an app or library, you
enable Android Runtime (ART) to optimize included code paths through
ahead-of-time (AOT) compilation, providing performance enhancements for every
new app install and every app update. This profile-guided optimization (PGO)
lets apps optimize startup, reduce interaction jank, and improve overall runtime
performance from the first launch for end users.
Compose performance considerations
Compose is distributed as a library instead of as part of the Android platform.
This approach lets the Compose team update Compose frequently and support a wide
range of Android versions. However, distributing Compose as a library imposes a
cost.
Android platform code is already compiled and installed on the device.
Libraries, however, need to be loaded when the app launches and interpreted JIT
when needed. This can slow the app on startup and when it uses a library feature
for the first time.
Benefits of baseline profiles
You can improve performance by defining Baseline Profiles. These profiles
define classes and methods needed on critical user journeys and are distributed
with your app's APK or AAB. During app installation, ART compiles this critical
code AOT so that it's ready for use when the app launches.
A good Baseline Profile definition is not always straightforward, and because
of this, Compose ships with one by default. You might not have to do any work to
see this benefit. However, the Baseline Profile that ships with Compose only
contains optimizations for the code within the Compose library.
Macrobenchmark
To get the best optimization, create a Baseline Profile
for your app that uses Macrobenchmark to cover critical user journeys. When
you define your own profile, you must test the profile to verify that it's
helping. A good way to do that is to write Macrobenchmark tests for your
app and check the test results as you write and revise your Baseline Profile.
For an example of how to write Macrobenchmark tests for your Compose UI, see the
Macrobenchmark Compose sample.
Additional Resources
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-11 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-11 UTC."],[],[],null,["# Use a baseline profile\n\n[Baseline Profiles](/baseline-profiles) improve code execution speed by about 30% from the first\nlaunch by avoiding interpretation and just-in-time (JIT) compilation steps for\nincluded code paths. By shipping a Baseline Profile in an app or library, you\nenable Android Runtime (ART) to optimize included code paths through\nahead-of-time (AOT) compilation, providing performance enhancements for every\nnew app install and every app update. This profile-guided optimization (PGO)\nlets apps optimize startup, reduce interaction jank, and improve overall runtime\nperformance from the first launch for end users.\n\nCompose performance considerations\n----------------------------------\n\nCompose is distributed as a library instead of as part of the Android platform.\nThis approach lets the Compose team update Compose frequently and support a wide\nrange of Android versions. However, distributing Compose as a library imposes a\ncost.\n\nAndroid platform code is already compiled and installed on the device.\nLibraries, however, need to be loaded when the app launches and interpreted JIT\nwhen needed. This can slow the app on startup and when it uses a library feature\nfor the first time.\n\nBenefits of baseline profiles\n-----------------------------\n\nYou can improve performance by defining [Baseline Profiles](/topic/performance/baselineprofiles/overview). These profiles\ndefine classes and methods needed on critical user journeys and are distributed\nwith your app's APK or AAB. During app installation, ART compiles this critical\ncode AOT so that it's ready for use when the app launches.\n\nA good Baseline Profile definition is not always straightforward, and because\nof this, Compose ships with one by default. You might not have to do any work to\nsee this benefit. However, the Baseline Profile that ships with Compose only\ncontains optimizations for the code within the Compose library.\n\n### Macrobenchmark\n\nTo get the best optimization, [create a Baseline Profile](/topic/performance/baselineprofiles/create-baselineprofile)\nfor your app that uses [Macrobenchmark](/studio/profile/macrobenchmark-overview) to cover critical user journeys. When\nyou define your own profile, you must test the profile to verify that it's\nhelping. A good way to do that is to write [Macrobenchmark](/studio/profile/macrobenchmark-overview) tests for your\napp and check the test results as you write and revise your Baseline Profile.\n\nFor an example of how to write Macrobenchmark tests for your Compose UI, see the\n[Macrobenchmark Compose sample](https://github.com/android/performance-samples/tree/main/MacrobenchmarkSample).\n\nAdditional Resources\n--------------------\n\n- **[App performance guide](/topic/performance/overview)**: Discover best practices, libraries, and tools to improve performance on Android.\n- **[Inspect Performance](/topic/performance/inspecting-overview):** Inspect app performance.\n- **[Benchmarking](/topic/performance/benchmarking/benchmarking-overview):** Benchmark app performance.\n- **[App startup](/topic/performance/appstartup/analysis-optimization):** Optimize app startup.\n- **[Baseline profiles](/baseline-profiles):** Understand baseline profiles."]]