Overview of system tracing

Recording device activity over a short period of time is known as system tracing. System tracing produces a trace file that can be used to generate a system report. This report helps you identify how best to improve your app or game's performance.

The Android platform provides several different options for capturing traces:

  • System Tracing app
  • Systrace command-line tool
  • Perfetto command-line tool

The System Tracing app is an Android tool that saves device activity to a trace file. On a device running Android 10 (API level 29) or later, trace files are saved in Perfetto format (see below). On a device running an earlier version of Android, trace files are saved in the Systrace format.

Systrace is a legacy platform-provided command-line tool that records device activity over a short period of time in a compressed text file. The tool produces a report that combines data from the Android kernel, such as the CPU scheduler, disk activity, and app threads.

Perfetto is the new platform-wide tracing tool introduced in Android 10. It is a more general and sophisticated open-source tracing project for Android, Linux, and Chrome. It offers a superset of data sources compared to Systrace and allows you to record arbitrarily long traces in a protobuf-encoded binary stream. You can open these traces in the Perfetto UI.

Screen capture of Perfetto
trace view

Figure 1. A sample Perfetto trace view, which shows about 20 seconds of interaction with an app

Screen capture of Systrace
report

Figure 2. A sample Systrace HTML report, which shows 5 seconds of interaction with an app

Both reports provide an overall picture of an Android device's system processes for a given period of time. The report also inspects the captured tracing information to highlight problems that it observes, such as UI jank or high power consumption.

Perfetto and Systrace are interoperable:

System tracing guides

To learn more about system tracing tools, see the following guides:

System Tracing system app
Explains how to capture a system trace directly on any device running Android 9 (API level 28) or higher.
Systrace command-line reference
Defines the different options and flags that you can pass into the command-line interface for Systrace.
Running Perfetto using ADB
Describes how to run the perfetto command-line tool to capture traces.
Running Perfetto
External documentation that describes how to build and run the perfetto command-line tool to capture traces.
Perfetto UI
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.
Navigate a Systrace report
Lists the elements of a typical report, presents keyboard shortcuts for navigating through the report, and describes how to identify types of performance problems.
Define custom events
Describes how you can apply custom labels to specific sections of your code, allowing for easier root-cause analysis in Systrace or Perfetto.