PerfettoTrace


@RequiresApi(value = 23)
@ExperimentalPerfettoCaptureApi
class PerfettoTrace


Summary

Public companion functions

Unit
record(
    fileLabel: String,
    appTagPackages: List<String>,
    userspaceTracingPackage: String?,
    traceCallback: ((PerfettoTrace) -> Unit)?,
    block: () -> Unit
)

Record a Perfetto System Trace for the specified block.

Unit
record(
    fileLabel: String,
    config: PerfettoConfig,
    highlightPackage: String,
    userspaceTracingPackage: String?,
    traceCallback: ((PerfettoTrace) -> Unit)?,
    block: () -> Unit
)

Record a Perfetto System Trace for the specified block, with a fully custom Perfetto config, either text or binary.

Public constructors

Public properties

String

Absolute file path of the trace.

Public companion functions

record

Added in 1.2.0
fun record(
    fileLabel: String,
    appTagPackages: List<String> = listOf(InstrumentationRegistry.getInstrumentation().targetContext.packageName),
    userspaceTracingPackage: String? = null,
    traceCallback: ((PerfettoTrace) -> Unit)? = null,
    block: () -> Unit
): Unit

Record a Perfetto System Trace for the specified block.

PerfettoTrace.record("myTrace") {
// content in here is traced to myTrace_<timestamp>.perfetto_trace
}

Reentrant Perfetto trace capture is not supported, so this API may not be combined with BenchmarkRule, MacrobenchmarkRule, or PerfettoTraceRule.

If the block throws, the trace is still captured and passed to traceCallback.

record

Added in 1.2.0
fun record(
    fileLabel: String,
    config: PerfettoConfig,
    highlightPackage: String = InstrumentationRegistry.getInstrumentation().targetContext.packageName,
    userspaceTracingPackage: String? = null,
    traceCallback: ((PerfettoTrace) -> Unit)? = null,
    block: () -> Unit
): Unit

Record a Perfetto System Trace for the specified block, with a fully custom Perfetto config, either text or binary.

PerfettoTrace.record("myTrace", config = """...""") {
// content in here is traced to myTrace_<timestamp>.perfetto_trace
}

Reentrant Perfetto trace capture is not supported, so this API may not be combined with BenchmarkRule, MacrobenchmarkRule, or PerfettoTraceRule.

If the block throws, the trace is still captured and passed to traceCallback.

Public constructors

PerfettoTrace

Added in 1.2.0
PerfettoTrace(path: String)

Public properties

path

Added in 1.2.0
val pathString

Absolute file path of the trace.

Note that the trace is not guaranteed to be placed into an app-accessible directory, and may require shell commands to access.