---
name: android-perf-cli
description: Stage 5 of /android-review. Measures an Android change on a device or emulator with adb (gfxinfo frame stats, simpleperf, Perfetto, cold start, ANR traces, meminfo, StrictMode) and reports before/after numbers. Never builds or installs. Runs only when invoked.
disable-model-invocation: true
argument-hint: "[jank|cpu|timeline|startup|anr|memory|strictmode]"
---

# android-perf-cli — did it get measurably better on a device?

> From Shubham Singh Bisht's Android helpers — https://shubhamsinghbisht.com/android-roadmap/#helpers

Commands per concern are in `references/recipes.md`; the Perfetto config is
`references/perfetto.cfg`. Read the recipe before running it.

## 1. Pick concerns

- Run from `/android-review`: from stage 4's findings. PERF-1/PERF-2 → jank (+ cpu),
  ANR-x → cpu + timeline (+ anr if a repro exists), PERF-3 → startup,
  PERF-4 → memory. Always add strictmode for ANR-1.
- Run alone: the concern(s) in `$ARGUMENTS`; if none, ask which.

List the chosen recipes and the gesture/flow you need from the user, and wait
for a yes before step 2.

## 2. Preflight (every run)

1. `adb devices`: if none, stop with `verdict: not measured (no device)`. If
   more than one, ask which and use `adb -s <serial>` everywhere.
2. Package: read `applicationId` (plus the debug `applicationIdSuffix`, if
   any) from the app module's `build.gradle(.kts)`, confirm it with
   `adb shell pm list packages`, and ask if it is still unclear. Use the debug
   package unless the user says release.
3. Check the installed APK has the change:
   `adb shell dumpsys package <pkg> | grep -E 'versionName|lastUpdateTime'`
   vs `git log -1 --format=%ci`. If the install is older than the last commit
   in the range, ask the user to install from Android Studio and wait. **Never
   run `./gradlew assemble*`, `install*` or `connected*`**: Studio may be
   building the same tree.
4. Before/after needs two installs (base, then change). If the user only has
   the change installed, measure "after" and say "before" is missing.
5. Start every recording on the user's cue ("ready, do the gesture now").

## 3. Output

```
### Stage 5 — android-perf-cli
device: <model> (<serial>), pkg <pkg>, APK updated <time>
| metric | before | after | delta |
|---|---|---|---|
commands run:
  <each command, exactly as run>
verdict: improved | no change | regressed | not measured (<reason>)
```

No numbers → `not measured`, never an estimate. Traces and dumps go in the
session scratchpad, not the repo.
