androidx.benchmark.traceprocessor


Interfaces

Classes

Insight

Individual case of a problem identified in a given trace (from a specific iteration).

Cmn
Insight.Category

Category represents general expectations that have been violated by an insight - e.g. JIT shouldn't take longer than XX ms, or trampoline activities shouldn't be used.

Cmn
PerfettoTrace
Cmn
PerfettoTrace.Link

Represents a link to a given PerfettoTrace, including a URL parameter string.

Cmn
Row

A Map that maps column name to value in a row result from a QueryResultIterator.

Cmn
StartupInsights
Cmn
TraceProcessor

Kotlin API for Perfetto Trace Processor, which enables SQL querying against the data stored in a Perfetto trace.

Cmn
TraceProcessor.Session

Handle to query sql data from a PerfettoTrace.

Cmn
TraceProcessor.Tracer
Cmn

Objects

Annotations

ExperimentalInsightApi

Annotation indicating experimental API for TraceProcessor-based Insights, finding and highlighting specific problems in a Trace.

Cmn
ExperimentalTraceProcessorApi

Annotation indicating experimental API for initializing Trace Processor.

Cmn

Top-level functions summary

String

Helper for fuzzy matching process name to package

Cmn
Row
rowOf(vararg pairs: Pair<StringAny?>)

Convenience for constructing a RowResult for given column values.

Cmn

Extension functions summary

Unit
@RequiresApi(value = 23)
@ExperimentalPerfettoCaptureApi
PerfettoTrace.Companion.record(
    fileLabel: String,
    appTagPackages: List<String>,
    userspaceTracingPackage: String?,
    traceCallback: ((PerfettoTrace) -> Unit)?,
    block: () -> Unit
)

Record a Perfetto System Trace for the specified block.

android
Unit
@RequiresApi(value = 23)
@ExperimentalPerfettoCaptureApi
PerfettoTrace.Companion.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.

android
T

Starts a Perfetto Trace Processor shell server in http mode, loads a trace and executes the given block.

android
T
@ExperimentalTraceProcessorApi
@RequiresApi(value = 23)
<T : Any?> TraceProcessor.Companion.runServer(
    timeout: Duration,
    block: TraceProcessor.() -> T
)

Starts a Perfetto Trace Processor shell server in http mode, loads a trace and executes the given block.

android

Top-level functions

processNameLikePkg

fun processNameLikePkg(pkg: String): String

Helper for fuzzy matching process name to package

fun rowOf(vararg pairs: Pair<StringAny?>): Row

Convenience for constructing a RowResult for given column values.

Useful when asserting expected query results in tests.

Extension functions

@RequiresApi(value = 23)
@ExperimentalPerfettoCaptureApi
fun PerfettoTrace.Companion.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.

@RequiresApi(value = 23)
@ExperimentalPerfettoCaptureApi
fun PerfettoTrace.Companion.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.

runServer

@ExperimentalTraceProcessorApi
@RequiresApi(value = 23)
fun <T : Any?> TraceProcessor.Companion.runServer(block: TraceProcessor.() -> T): T

Starts a Perfetto Trace Processor shell server in http mode, loads a trace and executes the given block. It stops the server after the block is complete

Uses a default timeout of 60 seconds.

Parameters
block: TraceProcessor.() -> T

Command to execute using trace processor

runServer

@ExperimentalTraceProcessorApi
@RequiresApi(value = 23)
fun <T : Any?> TraceProcessor.Companion.runServer(
    timeout: Duration,
    block: TraceProcessor.() -> T
): T

Starts a Perfetto Trace Processor shell server in http mode, loads a trace and executes the given block. It stops the server after the block is complete

Parameters
timeout: Duration

waiting for the server to start. If less or equal to zero uses 60 seconds

block: TraceProcessor.() -> T

Command to execute using trace processor