generating-baseline-profiles

Generate and measure Jetpack Compose Baseline Profiles with Macrobenchmark for startup and scroll performance.

Updated May 31, 2026
One-click install
npx skills add https://github.com/decoutkhanqindev/Lich-Viet-Loc-Phat --skill generating-baseline-profiles-decoutkhanqindev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: generating-baseline-profiles
Source: https://github.com/decoutkhanqindev/Lich-Viet-Loc-Phat/tree/main/.claude/skills/generating-baseline-profiles
Command: npx skills add https://github.com/decoutkhanqindev/Lich-Viet-Loc-Phat --skill generating-baseline-profiles-decoutkhanqindev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Jetpack Compose ships unbundled from the Android platform, so Compose apps run interpreted on first launch, causing slow cold startup and janky first-scroll. This Skill walks through generating a Baseline Profile (an AOT compilation hint list shipped in the APK) and proving with Macrobenchmark that it actually improved startup and frame timing. ## Core Features & Use Cases - Baseline Profile generation: Scaffolds the AGP 8.2+ Baseline Profile Generator module and writes a BaselineProfileRule journey covering cold startup plus at least one scroll, producing baseline-prof.txt packaged at assets/dexopt/baseline.prof. - Macrobenchmark measurement: Measures with MacrobenchmarkRule under CompilationMode.Partial(BaselineProfileMode.Require) so a missing profile fails loudly, reporting StartupTimingMetric and FrameTimingMetric medians against a CompilationMode.None A/B sibling. - Accurate TTFD: Wires ReportDrawn / ReportDrawnWhen / ReportDrawnAfter from androidx.activity.compose so timeToFullDisplay reflects the meaningful first frame instead of undercounting. - Use Case: Before a release, a developer notices cold startup feels slow on a low-end device. Use this Skill to generate a profile covering startup and feed scroll, verify it ships in the APK, and produce median cold-start and P95 frame-overrun numbers proving the improvement. ## Quick Start Generate a Baseline Profile for my Compose app covering cold startup and feed scrolling, then measure the startup and frame timing improvement with Macrobenchmark on a release build.

Frequently Asked Questions about generating-baseline-profiles

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate a Baseline Profile for a Jetpack Compose app?▼

Add the Baseline Profile Generator module via Android Studio (AGP 8.2+), write a BaselineProfileRule.collect test covering startup plus a scroll journey, then run ./gradlew :app:generateBaselineProfile. The profile lands at app/src/<variant>/generated/baselineProfiles/baseline-prof.txt.

How do I measure Compose startup performance with Macrobenchmark?▼

Use MacrobenchmarkRule.measureRepeated with StartupTimingMetric, StartupMode.COLD, and CompilationMode.Partial(BaselineProfileMode.Require) on a release build. Report medians across at least 10 iterations, and compare against a CompilationMode.None sibling test to prove the profile's effect.

Why is my Baseline Profile not improving app performance?▼

The profile likely is not packaged in the APK. Verify assets/dexopt/baseline.prof exists via Build > Analyze APK; if missing, add baselineProfile(project(":baselineprofile")) to the app module dependencies. Also confirm you measured a release build, not debug.

Can I measure Compose performance in a debug build?▼

No. Debug builds run Compose interpreted with Live Literals, inflating cold-start numbers 2-4x and distorting frame timing. Measurement only counts on a release variant with R8 minification on a physical low-end device or aosp_cf_x86_64_phone-userdebug Cuttlefish.

What is the difference between timeToInitialDisplay and timeToFullDisplay?▼

timeToInitialDisplay is when the first frame draws; timeToFullDisplay (TTFD) fires when the app calls ReportDrawn, ReportDrawnWhen, or ReportDrawnAfter from androidx.activity.compose. Without those calls, TTFD falls back to timeToInitialDisplay and undercounts real user wait time.

When should I not use Baseline Profiles?▼

Skip them during early prototyping when screens are still churning, since there are no stable hot paths to encode. They also do not replace recomposition debugging or compile-time stability checks, which are separate concerns handled by other tools.