ComponentsSystrace

This is intended as a hook into android.os.Trace, but allows you to provide your own functionality. Use it as

ComponentsSystrace.beginSection("tag"); ... ComponentsSystrace.endSection(); in Java. Or as

ComponentsSystrace.trace("tag") { ... } in Kotlin. As a default, it simply calls android.os.Trace (see DefaultComponentsSystrace). You may supply your own with ComponentsSystrace.provide.

Properties

Link copied to clipboard
Link copied to clipboard
var systrace: Systracer

Functions

Link copied to clipboard

Writes a trace message to indicate that a given section of code has begun. Must be followed by a call to .endAsyncSection using the same tag. 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.

Link copied to clipboard

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.

Link copied to clipboard
fun beginSectionWithArgs(name: String): Systracer.ArgsBuilder
Link copied to clipboard
fun endAsyncSection(name: String, cookie: Int)

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 tag, name and cookie.

Link copied to clipboard

Writes a trace message to indicate that a given section of code has ended. This call must be preceded by a corresponding call to .beginSection. Calling this method will mark the end of the most recently begun section of code, so care must be taken to ensure that beginSection / endSection pairs are properly nested and called from the same thread.

Link copied to clipboard
fun provide(instance: Systracer)

This should be called exactly once at app startup, before any Litho work happens.

Link copied to clipboard
inline fun <T> trace(name: String, tracingBlock: () -> T): T

A convenience Kotlin API that can be used instead of manually calling ComponentsSystrace.beginSection and ComponentsSystrace.endSection.