ベースライン プロファイルを使用する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
ベースライン プロファイルにより、含まれるコードパスに対して解釈とジャストインタイム(JIT)コンパイルの手順を行う必要がなくなるため、初回起動からのコード実行速度が約 30% 向上します。アプリまたはライブラリにベースライン プロファイルを配布することで、Android ランタイム(ART)が事前(AOT)コンパイルによって含まれるコードパスを最適化し、すべての新規アプリのインストールとすべてのアプリ アップデートでパフォーマンスが向上します。このプロファイルに基づく最適化(PGO)を使用すると、エンドユーザーの初回起動時から、起動の最適化、インタラクション ジャンクの削減、全体的なランタイム パフォーマンスの向上が可能になります。
Compose のパフォーマンスに関する考慮事項
Compose は、Android プラットフォームの一部としてではなく、ライブラリとして配布されます。このアプローチにより、Compose チームは Compose を頻繁に更新し、幅広い Android バージョンをサポートできます。ただし、Compose をライブラリとして配布するとコストがかかります。
Android プラットフォーム コードはすでにコンパイルされ、デバイスにインストールされています。ただし、ライブラリは、アプリの起動時に JIT を読み込み、必要に応じて解釈する必要があります。これにより、アプリの起動時やライブラリ機能を初めて使用するときに、アプリの速度が低下する可能性があります。
ベースライン プロファイルのメリット
ベースライン プロファイルを定義すると、パフォーマンスを向上させることができます。これらのプロファイルは、クリティカル ユーザー ジャーニーに必要なクラスとメソッドを定義し、アプリの APK または AAB とともに配布されます。アプリのインストール中に、ART はこの重要なコードを AOT コンパイルし、アプリの起動時に使用できるようにします。
ベースライン プロファイルの定義は必ずしも簡単とは限りません。そのため、Compose にはベースライン プロファイルがデフォルトで付属しています。何もしなくても、このメリットが得られます。ただし、Compose に付属のベースライン プロファイルには、Compose ライブラリ内のコードの最適化のみが含まれています。
Macrobenchmark
最適な最適化を行うには、Macrobenchmark を使用してクリティカル ユーザー ジャーニーをカバーするアプリのベースライン プロファイルを作成します。独自のプロファイルを定義する場合は、プロファイルをテストして、有効性を検証する必要があります。そのためには、アプリの Macrobenchmark テストを作成し、ベースライン プロファイルの作成と変更を行うときにテスト結果を確認することをおすすめします。
Compose UI の Macrobenchmark テストを作成する方法の例については、Macrobenchmark Compose のサンプルをご覧ください。
その他のリソース
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 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."]]