There are multiple tools that are useful for inspecting and monitoring performance to help improve your app.
Understand performance locally with Benchmark libraries
- The Macrobenchmark library helps you measure larger end-user interactions, such as startup, interacting with the UI, and animations.
- The Microbenchmark library helps analyze performance of more granular, app-specific situations.
Understand performance in production
- Android vitals can help improve your app's performance by alerting you when various performance metrics exceed predetermined thresholds.
- The Firebase performance SDK collects various metrics about your app's performance. For example, you can use the SDK to measure the time between when the user opens the app and when the app becomes responsive, helping identify potential startup bottlenecks.
Profile locally with Android Studio
- Use Android Studio to record and view system traces or stack sampling traces.
- Record traces using Android Studio. For additional information, see the Performance Debugging video series.
- Use Simpleperf, a native stack sampling tool for Android, to profile both Android apps and native processes running on Android. It can profile both Java and C++ code on Android.
Advanced profiling tools: Perfetto tracing
- Perfetto is a platform-wide tracing tool available on Android 10 (API level 29) and higher. For more information, see the overview of Perfetto traces.
- Run Perfetto using ADB describes how to run the
perfetto
command-line tool to capture traces. - Record a trace through the cmdline describes how to build
and run the
perfetto
command-line tool to capture traces. - The Perfetto web-based trace viewer opens Perfetto traces and displays a complete report. You can also open Systrace traces in this viewer using the legacy UI option.