Measure startup, jank & leaks
Outcome: quantify startup latency, frame drops, unnecessary Compose recompositions, or retained memory objects before and after a code change—without dumping huge HPROF files.
Prerequisites
Section titled “Prerequisites”perf frames and perf startup run from the host against any installed app. perf leaks and layout recompositions --why require a debuggable app (and supported Compose 1.13+ metadata for --why). Always compare numbers on the same device or emulator; an emulator number reflects that emulator, not a budget physical phone.
Ask your agent
Section titled “Ask your agent”Measure cold startup and scroll jank on the Feed screen before and after mychange using Olef. Then navigate into Detail and back three times and run`olef perf leaks` to check for retained Activities, Fragments, or ViewModels.1. Verified cold, warm, and hot startup
Section titled “1. Verified cold, warm, and hot startup”Mixing cold and warm launches makes fake regressions and fake speedups easy to invent. olef perf startup verifies the Android LaunchState for every iteration and captures reportFullyDrawn() when your app emits it:
olef perf startup --app com.example.app --mode cold --iterations 5olef perf startup --app com.example.app --mode warm --iterations 52. Frame jank budgets
Section titled “2. Frame jank budgets”Reset gfxinfo framestats, exercise the scrolling or animation interaction, then sample percentiles (p50, p90, p95, p99), janky-frame counts, and software-rendering attribution:
olef perf frames reset --app com.example.app# Scroll or animate the screen under testolef ui swipe-ext up --scale 0.7olef perf frames sample --app com.example.app3. Bounded JVMTI leak chains (no HPROF dump)
Section titled “3. Bounded JVMTI leak chains (no HPROF dump)”After navigating through a screen and popping back (or rotating), scan for retained destroyed Activities, Fragments, detached Views, and cleared ViewModels:
olef perf leaks --app com.example.appperf leaks runs a time- and pause-capped JVMTI heap walk inside the debuggable process and returns shortest GC-root retention paths directly as structured JSON.
4. Find why Compose recomposed
Section titled “4. Find why Compose recomposed”Knowing a composable recomposed is half the answer; knowing what state read triggered it tells the agent what to fix:
olef --project-root . layout recompositions --app com.example.app --whyLimits
Section titled “Limits”perf leaksis a bounded diagnostic walk designed to stay responsive; it surfaces common Android lifecycle leaks rather than acting as a full heap profiler.- Emulator frame timings are useful for relative before/after comparisons, not absolute production SLAs. For representative hardware measurements, run on a USB phone or lease a physical device via Cloud emulators & real phones.
See olef perf and olef layout for all flags and budget options.