TraceCompat

public final class TraceCompat


Writes trace events to the system trace buffer. These trace events can be collected and visualized using the Systrace tool.

This tracing mechanism is independent of the method tracing mechanism offered by startMethodTracing. In particular, it enables tracing of events that occur across multiple processes.

For information about using the Systrace tool, read Overview of system tracing.

Summary

Public constructors

Public methods

static void
beginAsyncSection(@NonNull String methodName, int cookie)

Writes a trace message to indicate that a given section of code has begun.

static void
beginSection(@NonNull String sectionName)

Writes a trace message to indicate that a given section of code has begun.

static void
endAsyncSection(@NonNull String methodName, int cookie)

Writes a trace message to indicate that the current method has ended.

static void

Writes a trace message to indicate that a given section of code has ended.

static boolean

Checks whether or not tracing is currently enabled.

static void
setCounter(@NonNull String counterName, int counterValue)

Writes trace message to indicate the value of a given counter.

Public constructors

TraceCompat

public final TraceCompat()

Public methods

beginAsyncSection

public static void beginAsyncSection(@NonNull String methodName, int cookie)

Writes a trace message to indicate that a given section of code has begun. Must be followed by a call to endAsyncSection with the same methodName and cookie. Unlike beginSection and endSection, asynchronous events do not need to be nested. The name and cookie used to begin an event must be used to end it.

Parameters
@NonNull String methodName

The method name to appear in the trace.

int cookie

Unique identifier for distinguishing simultaneous events

beginSection

public static void beginSection(@NonNull String sectionName)

Writes a trace message to indicate that a given section of code has begun. This call must be followed by a corresponding call to endSection on the same thread.

At this time the vertical bar character '|', newline character '\n', and null character '\0' are used internally by the tracing mechanism. If sectionName contains these characters they will be replaced with a space character in the trace.

Parameters
@NonNull String sectionName

The name of the code section to appear in the trace. This may be at most 127 Unicode code units long.

endAsyncSecti