Ir al contenido

Más visitados

Visitados recientemente


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.

Utilizamos cookies para registrar tus preferencias de idioma y visualización de este sitio web.

Recibe novedades y consejos para desarrolladores de Android que te ayudarán a alcanzar el éxito en Google Play.

* Campos obligatorios

¡Ya está!

Seguir a Google Developers en WeChat

¿Quieres navegar por el sitio web en ?

Has solicitado que la página aparezca en , pero tu idioma preferido en este sitio web es el .

¿Quieres cambiar tu preferencia de idioma y navegar por este sitio web en ? Si prefieres dejarlo para más tarde, usa el menú de idioma que se encuentra en la parte inferior de cada página web.

Para esta clase se necesita un nivel de API o superior

La documentación está oculta porque el nivel de API que has seleccionado para ella es . Cambia el nivel de API de la documentación en el selector situado encima del menú de navegación de la izquierda.

Para obtener más información sobre cómo especificar el nivel de API que requiere tu aplicación, lee el artículo Supporting Different Platform Versions (Compatibilidad con diferentes versiones de la plataforma).

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)