There are multiple tools that can be useful for inspecting and monitoring opportunities for performance improvements in your app.
Understanding performance locally: Benchmarking 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, application-specific situations.
Understanding 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 can also collect 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.
Profiling locally: Android Studio
- Use Android Studio to record and view system traces or stack sampling traces.
- To begin recording traces using Android Studio, see Record traces. For additional information, check out this video series.
- Simpleperf is a native stack sampling tool for Android. It can be used to profile both Android applications 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 Overview of Perfetto traces.
- Running Perfetto using ADB describes how to run the Perfetto command-line tool to capture traces.
- Running Perfetto 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.