# androidx.benchmark.traceprocessor

*** ** * ** ***

Android/JVM

## Interfaces

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/Insight.Provider` |   | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/ServerLifecycleManager` |   | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/TraceProcessor.EventCallback` |   | android |

## Classes

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/Insight` | Individual case of a problem identified in a given trace (from a specific iteration). | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/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. | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/PerfettoTrace` |   | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/PerfettoTrace.Link` | Represents a link to a given PerfettoTrace, including a URL parameter string. | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/Row` | A Map that maps column name to value in a row result from a `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/QueryResultIterator`. | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/StartupInsights` |   | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/TraceProcessor` | Kotlin API for [Perfetto Trace Processor](https://perfetto.dev/docs/analysis/trace-processor), which enables SQL querying against the data stored in a Perfetto trace. | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/TraceProcessor.Handle` |   | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/TraceProcessor.Session` | Handle to query sql data from a `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/PerfettoTrace`. | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/TraceProcessor.Session.Handle` |   | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/TraceProcessor.Tracer` |   | android |

## Objects

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/PerfettoTrace.Companion` |   | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/TraceProcessor.Companion` |   | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/TraceProcessor.EventCallback.Noop` |   | android |

## Annotations

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/ExperimentalInsightApi` | Annotation indicating experimental API for TraceProcessor-based Insights, finding and highlighting specific problems in a Trace. | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/ExperimentalTraceProcessorApi` | Annotation indicating experimental API for initializing Trace Processor. | android |

## Top-level functions summary

|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/package-summary#processNameLikePkg(kotlin.String)(pkg: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Helper for fuzzy matching process name to package | android |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/Row` | `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/package-summary#rowOf(kotlin.Array)(vararg pairs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>)` Convenience for constructing a RowResult for given column values. | android |

## Extension functions summary

|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/benchmark/perfetto/ExperimentalPerfettoCaptureApi https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/PerfettoTrace.Companion.https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/package-summary#(androidx.benchmark.traceprocessor.PerfettoTrace.Companion).record(kotlin.String,kotlin.collections.List,kotlin.String,kotlin.Function1,kotlin.Function0)( fileLabel: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, appTagPackages: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html>, userspaceTracingPackage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?, traceCallback: ((https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/PerfettoTrace) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)?, block: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Record a Perfetto System Trace for the specified `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/package-summary#(androidx.benchmark.traceprocessor.PerfettoTrace.Companion).record(kotlin.String,kotlin.collections.List,kotlin.String,kotlin.Function1,kotlin.Function0)`. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/benchmark/perfetto/ExperimentalPerfettoCaptureApi https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/PerfettoTrace.Companion.https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/package-summary#(androidx.benchmark.traceprocessor.PerfettoTrace.Companion).record(kotlin.String,androidx.benchmark.perfetto.PerfettoConfig,kotlin.String,kotlin.Function1,kotlin.Function0)( fileLabel: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, config: https://developer.android.com/reference/kotlin/androidx/benchmark/perfetto/PerfettoConfig, userspaceTracingPackage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?, traceCallback: ((https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/PerfettoTrace) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)?, block: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Record a Perfetto System Trace for the specified `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/package-summary#(androidx.benchmark.traceprocessor.PerfettoTrace.Companion).record(kotlin.String,androidx.benchmark.perfetto.PerfettoConfig,kotlin.String,kotlin.Function1,kotlin.Function0)`, with a fully custom Perfetto config, either text or binary. | android |

## Top-level functions

### processNameLikePkg

android Artifact: [androidx.benchmark:benchmark-traceprocessor](https://developer.android.com/jetpack/androidx/releases/benchmark) [View Source](https://cs.android.com/search?q=file:androidx/benchmark/traceprocessor/TraceProcessor.kt+function:processNameLikePkg) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/benchmark#1.4.0)

```
fun processNameLikePkg(pkg: String): String
```

Helper for fuzzy matching process name to package

### rowOf

android Artifact: [androidx.benchmark:benchmark-traceprocessor](https://developer.android.com/jetpack/androidx/releases/benchmark) [View Source](https://cs.android.com/search?q=file:androidx/benchmark/traceprocessor/Row.kt+function:rowOf)

```
fun rowOf(vararg pairs: Pair<String, Any?>): Row
```

Convenience for constructing a RowResult for given column values.

Useful when asserting expected query results in tests.

## Extension functions

### PerfettoTrace.Companion.record

android Artifact: [androidx.benchmark:benchmark-traceprocessor](https://developer.android.com/jetpack/androidx/releases/benchmark) [View Source](https://cs.android.com/search?q=file:androidx/benchmark/traceprocessor/PerfettoTrace.kt+function:record) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/benchmark#1.4.0)

```
@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 `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/package-summary#(androidx.benchmark.traceprocessor.PerfettoTrace.Companion).record(kotlin.String,kotlin.collections.List,kotlin.String,kotlin.Function1,kotlin.Function0)`.

```kotlin
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 `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/package-summary#(androidx.benchmark.traceprocessor.PerfettoTrace.Companion).record(kotlin.String,kotlin.collections.List,kotlin.String,kotlin.Function1,kotlin.Function0)`.

### PerfettoTrace.Companion.record

android Artifact: [androidx.benchmark:benchmark-traceprocessor](https://developer.android.com/jetpack/androidx/releases/benchmark) [View Source](https://cs.android.com/search?q=file:androidx/benchmark/traceprocessor/PerfettoTrace.kt+function:record) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/benchmark#1.5.0)

```
@ExperimentalPerfettoCaptureApi
fun PerfettoTrace.Companion.record(
    fileLabel: String,
    config: PerfettoConfig,
    userspaceTracingPackage: String? = null,
    traceCallback: ((PerfettoTrace) -> Unit)? = null,
    block: () -> Unit
): Unit
```

Record a Perfetto System Trace for the specified `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/package-summary#(androidx.benchmark.traceprocessor.PerfettoTrace.Companion).record(kotlin.String,androidx.benchmark.perfetto.PerfettoConfig,kotlin.String,kotlin.Function1,kotlin.Function0)`, with a fully custom Perfetto config, either text or binary.

```kotlin
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 `https://developer.android.com/reference/kotlin/androidx/benchmark/traceprocessor/package-summary#(androidx.benchmark.traceprocessor.PerfettoTrace.Companion).record(kotlin.String,androidx.benchmark.perfetto.PerfettoConfig,kotlin.String,kotlin.Function1,kotlin.Function0)`.