Skip to main content

ADB-based Android performance metric recorder with live TUI and HTML report

Project description

androidperf

A CLI that records Android app runtime performance over ADB — CPU, RAM, network, FPS/jank, battery, thermal, and screen transitions — draws a live terminal dashboard while it runs, and drops a self-contained HTML report at the end.

┌── androidperf · com.example.app · Pixel 7 (sdk 34)     samples 42  elapsed 00:41 ──┐
│ screen HomeActivity     battery 87% charging 31°C      thermal moderate skin 35°C  │
├──── CPU ────┬── Memory ─────────┬──── Network ────┬──── FPS ────┐
│             │                   │                 │             │
│   19.2 %    │  Total PSS 199 MB │   ↓ rx 5 KB/s   │  fps  58.2  │
│    ▁▂▄▆█    │  Java       39 MB │   ↑ tx 2 KB/s   │  jank 3.1 % │
│             │  Native     44 MB │                 │  p95    18  │
│ per-process │  Graphics   20 MB │       ▁▂        │     █▆▄▂▁   │
│     CPU     │         ▁▂        │       ▁▂        │             │
└─────────────┴───────────────────┴─────────────────┴─────────────┘
                             Ctrl+C to stop

Requirements

Python 3.11 or newer
adb Android Platform Tools on $PATH. macOS: brew install --cask android-platform-tools. Debian/Ubuntu: sudo apt install adb. Windows/other: https://developer.android.com/tools/releases/platform-tools. Verify with adb version.
Android device Physical device or emulator running Android 7.0 (SDK 24) or newerdumpsys gfxinfo framestats needs SDK 24+.
USB debugging Enabled in Developer Options, and the host authorized (adb devices shows the serial as device, not unauthorized).
Python deps Installed automatically: adbutils, typer, rich, jinja2, plotly, pandas.

adb is not a Python package — it's a standalone binary. If androidperf devices says "command not found", that's the missing piece.

Install

pipx install androidperf          # recommended — isolated, globally available
# or
pip install androidperf           # into the current environment

From source (until the package is on PyPI, or if you want to hack on it):

git clone https://github.com/jitinsharma/androidperf.git
cd androidperf

# Option A — globally available, isolated venv managed by pipx:
pipx install .
pipx install --editable .          # if you plan to edit the code

# Option B — a regular venv with the dev extras (pytest, ruff):
python3.11 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

Quickstart

# 1. See connected devices
androidperf devices

# 2. Find the package you want to profile
androidperf packages --filter com.android

# 3. Search app and record
androidperf record

# 3. Launch the app and record for 60s at 1s cadence
androidperf record --package com.android.settings --interval 1 --duration 60

If --package is omitted, record drops into an interactive prompt: type a substring, pick a number.

Attach to an already-running app instead of launching it:

androidperf record --package com.example.app --no-launch

Stop early with Ctrl+C — the JSON and HTML are still written with whatever samples were collected. After the session ends, a stat-card panel prints in the terminal with the same summary numbers that appear in the HTML report.

Each run writes to runs/<timestamp>-<pkg>/:

  • samples.json — raw time-series data, easy to diff or re-plot
  • report.html — single self-contained file, opens offline

What gets measured

Metric Source
CPU % (per-core summed) top -n 1 -b -p <pid>
RAM: PSS / Java / Native / Graphics / Code / Stack dumpsys meminfo <package>
Network rx/tx (per-tick deltas) /proc/net/xt_qtaguid/stats (falls back to dumpsys netstats --uid=<uid> on Android 10+)
FPS, jank %, frame p50/p90/p95/p99 dumpsys gfxinfo <package> (reset between ticks)
Battery: level, temp, voltage, status dumpsys battery
Thermal: status, skin/cpu/gpu/battery °C dumpsys thermalservice
Screen transitions (as timeline events) dumpsys activity activities

CPU is reported as top's raw %CPU — i.e., summed across cores. 200% means the process is using two cores worth of time. This is the same convention used by Android Studio's CPU profiler.

HTML report

Each chart gets vertical dashed markers for every screen transition, so jank spikes line up with user navigation. The report also includes:

  • Summary stat cards (averages, peaks, network totals, battery delta).
  • A flat "Screen timeline" list of every transition with elapsed time.
  • Interactive Plotly charts — zoom, pan, hover tooltips, toggle traces in the legend. No network required to view the report; plotly.js is inlined.

Commands

Command Purpose
androidperf devices List connected ADB devices.
androidperf packages [--filter X] [--serial S] [--limit N] List installed packages.
androidperf record --package PKG [...] Record a session; write JSON + HTML.
androidperf report SAMPLES_JSON Regenerate HTML from an existing run.
androidperf version Print installed version.

Development

pytest -q         # parser + report tests (no device required)
ruff check src    # lint

Parsers live under src/androidperf/collectors/ and are tested against captured command output in tests/fixtures/. When you hit a device whose output differs, add a fixture file + an assertion and the parser can be updated against it without any device plugged in.

Layout

src/androidperf/
├── cli.py                # Typer entry point
├── device.py             # adb detection, package list, app launch
├── session.py            # polling loop, signal handling, JSON writer
├── summary.py            # shared summary-card computation (HTML + terminal)
├── collectors/           # cpu, memory, network, fps, battery, thermal, activity
├── ui/                   # live.py (Live dashboard) + summary.py (end-of-run panel)
└── report/               # Jinja2 + Plotly → self-contained HTML

See plan/ for architecture and future-direction docs.

License

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

androidperf-0.1.1.tar.gz (41.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

androidperf-0.1.1-py3-none-any.whl (31.1 kB view details)

Uploaded Python 3

File details

Details for the file androidperf-0.1.1.tar.gz.

File metadata

  • Download URL: androidperf-0.1.1.tar.gz
  • Upload date:
  • Size: 41.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for androidperf-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0f052b1b295a2d0731a62ac27f9e96505efb834bde2ebe815765753a5aa8f7db
MD5 319608c61f591c502a23f1d035e77c00
BLAKE2b-256 8e8c1239a79859c31047e5e71e75313901b5764faa50a3a00dd35e03c1b4f87f

See more details on using hashes here.

File details

Details for the file androidperf-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: androidperf-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 31.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for androidperf-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 381ae99367429a5c0cb068315933f4983db171eb77d664002357a546f9589c76
MD5 b2d14a1ace80de0cb5ae146c7f009e3f
BLAKE2b-256 0711c354ac445b1c7944a0b408803c8d8e5493f661e93584685ae80ad1d1f1ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page