PerfettoTraceKt

Added in 1.4.0-alpha07

public final class PerfettoTraceKt


Summary

Public methods

static final void
@RequiresApi(value = 23)
@ExperimentalPerfettoCaptureApi
record(
    @NonNull PerfettoTrace.Companion receiver,
    @NonNull String fileLabel,
    @NonNull List<@NonNull String> appTagPackages,
    String userspaceTracingPackage,
    Function1<@NonNull PerfettoTraceUnit> traceCallback,
    @NonNull Function0<Unit> block
)

Record a Perfetto System Trace for the specified block.

static final void
@RequiresApi(value = 23)
@ExperimentalPerfettoCaptureApi
record(
    @NonNull PerfettoTrace.Companion receiver,
    @NonNull String fileLabel,
    @NonNull PerfettoConfig config,
    @NonNull String highlightPackage,
    String userspaceTracingPackage,
    Function1<@NonNull PerfettoTraceUnit> traceCallback,
    @NonNull Function0<Unit> block
)

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

Public methods

@RequiresApi(value = 23)
@ExperimentalPerfettoCaptureApi
public static final void record(
    @NonNull PerfettoTrace.Companion receiver,
    @NonNull String fileLabel,
    @NonNull List<@NonNull String> appTagPackages,
    String userspaceTracingPackage,
    Function1<@NonNull PerfettoTraceUnit> traceCallback,
    @NonNull Function0<Unit> block
)

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
public static final void record(
    @NonNull PerfettoTrace.Companion receiver,
    @NonNull String fileLabel,
    @NonNull PerfettoConfig config,
    @NonNull String highlightPackage,
    String userspaceTracingPackage,
    Function1<@NonNull PerfettoTraceUnit> traceCallback,
    @NonNull Function0<Unit> block
)

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.