Skip to content

Most visited

Recently visited


Method Tracer

This tool was removed in Android Studio 3.0.

You should get the latest version of Android Studio and use the new CPU Profiler instead.

You can start a method trace from the CPU Monitor included with Android Monitor. It lets you view the call stack and timing information for your app. This information can help you optimize and debug your app.

Understanding the Method Trace Display

The method trace looks similar to the following figure:

Method Trace

The display shows the following information:

Field Description
Name The name of the method.
Invocation Count How many times the method was called.
Inclusive Time (microseconds) Time spent in the method and all of its children, either wall clock or thread time, depending on your selection in the x-axis menu.
Exclusive Time (microseconds) Time spent just in the method (excluding time spent in its children), either wall clock or thread time, depending on your selection in the x-axis menu.

Note: Running the method trace significantly affects CPU timings. Use the method trace to understand the flow of the program, but not for performance timings.

Performing a Method Trace in the CPU Monitor

To perform a method trace:

  1. Display a running app in the CPU Monitor.
  2. Start a trace by clicking Start Method Tracing Start Method Tracing icon to select it.
  3. To stop the trace, click Stop Method Tracing Stop Method Tracing icon to deselect it.
  4. The method trace appears in the Code Editor area.

    Android Studio creates the method trace file with the filename using the activity package (or project) name, year, month, day, hour, minute, and second of the capture, for example,

  5. Specify display options:
    • Select a Thread.
    • Select an x-axis time for the graphic and the method list:
      • Wall Clock Time - Total CPU time elapsed between the method call and return.
      • Thread Time - Total time during which the JRE scheduled the thread during call processing. It’s less than or equal to the Wall Clock Time: less if the JRE interrupted the thread, and equal if it didn’t. The thread might not run continuously; when it’s not executing, that time is excluded. If threads are interrupted often and it’s not by design, the interruptions affect app performance. However, an example of a by-design use is synchronous operations that take a long time, such as file transfers and reads from disk, where the method could be the asynchronous wrapper for the synchronous reader.
    • Optionally select Color by inclusive time.

    The graphic represents the wall clock or thread time for each method. Hover the cursor over the display to receive information about the method. This information also appears in the table.

Viewing a Saved Method Trace

After you do a method trace, Android Studio automatically stores it so you can view it again.

To examine a saved method trace:

  1. Click Captures icon in the main window.
  2. Or select View > Tools Windows > Captures.

    The Captures window appears.

  3. Open the Methods Tracing folder.
  4. Double-click the file to view it.

Sorting Method Trace Data

You can sort the data by method name, count, inclusive time, and exclusive time.

To sort method trace data:

Working with Method Trace Files

You can rename, locate, and delete a method trace file from within Android Studio.

Renaming a method trace file

Rename a method trace file from within Android Studio so it continues to appear in the Captures window.

To rename a method trace file:

  1. In the Captures window, right-click the file and select Rename.
  2. In the dialog, specify the name of the file and click OK.

Locating a method trace file on disk

You can quickly discover where Android Studio stored method trace files on disk.

To locate a method trace file on disk:

Note: If you move a method trace file, Android Studio no longer displays the file in the Captures window. To display it, use File > Open. Also, rename a file from the Captures window and not in the operating system file browser.

Deleting a method trace file

To delete a method trace file:

Android Studio deletes the file from the Captures dialog and from disk.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)