Let's build a performance measuring tool from scratch
summary
Live demo shows how to measure per-thread CPU by calling adb shell top -H and by reading /proc entries (parsing /proc/<pid>/task//stat ), converting clock ticks (getconf CLK_TCK = 100) into percentages, and sampling with a Kotlin script; caveat: minimum sampling is 1s and top itself can consume ~23% CPU. FPS counting comes from running atrace and counting choreographer.doFrame calls (example device reports ~120 fps). The tool built is open source at flashlight.dev*.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 4:20Flashlight goals
- 5:23ADB for app performance
- 9:39CPU usage with top
- 12:48Performance tool challenges
- 13:51Android top implementation
- 18:06Linux /proc filesystem
- 22:25Shell to Kotlin
- 27:26Live CPU with Kotlin
- 31:02CPU usage accuracy
- 33:10FPS with atrace
- 38:25Summary
related talks
43mPerformance in a Kotlin World
39mDeep-Diving Android Performance with Perfetto
45mPerformance in a Kotlin world
42mDebugging Application Performance
35mIn Search of Performance: the Subtle Art of Android Profiling
37mImproving app performance with benchmarking
43mBenchmarking your application
13mPerfetto Your App for Perfect Performance
