Package 

Class TraceCompat


  • @Deprecated() 
    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.

    • Method Summary

      Modifier and Type Method Description
      static boolean isEnabled() Checks whether or not tracing is currently enabled.
      static void beginSection(@NonNull() String sectionName) Writes a trace message to indicate that a given section of code has begun.
      static void endSection() Writes a trace message to indicate that a given section of code has ended.
      static void beginAsyncSection(@NonNull() String methodName, int cookie) Writes a trace message to indicate that a given section of code hasbegun.
      static void endAsyncSection(@NonNull() String methodName, int cookie) Writes a trace message to indicate that the current method has ended.
      static void setCounter(@NonNull() String counterName, int counterValue) Writes trace message to indicate the value of a given counter.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • isEnabled

         static boolean isEnabled()

        Checks whether or not tracing is currently enabled. This is useful to avoid intermediatestring creation for trace sections that require formatting. It is not necessaryto guard all Trace method calls as they internally already check this. However it isrecommended to use this to prevent creating any temporary objects that would then bepassed to those methods to reduce runtime cost when tracing isn't enabled.

      • beginSection

         static void beginSection(@NonNull() String sectionName)

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

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

        Parameters:
        sectionName - The name of the code section to appear in the trace.
      • endSection

         static void endSection()

        Writes a trace message to indicate that a given section of code has ended. This call mustbe preceeded by a corresponding call to beginSection. Calling this methodwill mark the end of the most recently begun section of code, so care must be taken toensure that beginSection / endSection pairs are properly nested and called from the samethread.

      • beginAsyncSection

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

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

        Parameters:
        methodName - The method name to appear in the trace.
        cookie - Unique identifier for distinguishing simultaneous events
      • endAsyncSection

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

        Writes a trace message to indicate that the current method has ended.Must be called exactly once for each call to beginAsyncSection using the same name and cookie.

        Parameters:
        methodName - The method name to appear in the trace.
        cookie - Unique identifier for distinguishing simultaneous events
      • setCounter

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

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

        Parameters:
        counterName - The counter name to appear in the trace.
        counterValue - The counter value.