Google is committed to advancing racial equity for Black communities. See how.

Android Tools and Infrastructure

This article describes the tools you can use to measure performance metrics and to test the user interface.

System performance tools

Boot time

To profile boot timing, use the bootanalyze tool. For each specific product, modify the config.yaml file to include events you want to search for. config.yaml should appear as follows:

  stop_event: <logcat log message which will terminate log collection after reboot>
  events:
    event1_name: <pattern that matches log message>
    event2_
    ...

On some devices, booting the clock may display an incorrect time for the first few seconds. While the bootanalyze tool can accommodate a time correction out-of-the-box, you can provide an optional time correction pattern in config.yaml. Optimizing Boot Times explains how to improve boot time using components such as Bootloader, Device Kernel, I/O tuning, Boot animation, and the SELinux policy.

App start-up time

Users expect apps to be quick to load and responsive. App Startup Time details the internals of the launch process and discusses how to profile and optimize startup performance.

User interface

User interface (UI) performance testing ensures that your app meets functional requirements and that user interactions with your app are smooth, run at a consistent 60 frames per second (see Android Performance Patterns: Why 60fps?), and all without dropping or delaying frames.

For more information, see Test UI Performance and JankTest.

Memory

You can inspect app memory usage in one of two ways:

  • Over time, using procstats.
  • Snapshot in time, using meminfo.

For details, see:

Central processing unit

  • To profile Android applications and native processes running on Android, use Simpleperf, a native central processing unit (CPU) profiling tool for Android. Simpleperf can profile Java and C++ code on Android. The Simpleperf executable can run on Android releases later than L and Python scripts can be used on Android releases later than N.

    Simpleperf is part of the Android Open Source Project. The source code is located at Simpleperf. For details, see the Simpleperf documentation.

  • To inspect your app's CPU usage and thread activity in real time while interacting with your app, use the CPU Profiler. Doing so has many advantages, such as providing a faster and smoother user experience and preserving device battery life. In addition, you can inspect the details of recorded method, function, and system traces.

User interface tests and frameworks

To test the UI and frameworks, use these tools:

  • To automate end-to-end user interface testing, use the UI Automator and the open source auto-specific Helpers provided with AOSP.

  • To automate the testing of end-to-end Bluetooth connectivity, use the open source Google Mobly framework.

  • To write concise, beautiful, and reliable Android UI tests, use Espresso.

  • To build, install, and run Android tests locally, use the Atest command line tool.

    $ atest [optional-arguments] test-to-run
    
  • To test drive your Android code, use Robolectric (tests run in seconds in the JVM of a workstation).