PerfettoRule

@RestrictTo([Scope.LIBRARY_GROUP_PREFIX]) class PerfettoRule : TestRule
kotlin.Any
   ↳ androidx.benchmark.junit4.PerfettoRule

Add this rule to record a Perfetto trace for each test on Q+ devices.

Relies on either AGP's additionalTestOutputDir copying, or (in Jetpack CI), additionalTestOutputFile_*** copying.

When invoked locally with Gradle, file will be copied to host path like the following:

out/androidx/benchmark/benchmark-macro/build/outputs/connected_android_test_additional_output/debugAndroidTest/connected/<deviceName>/androidx.mypackage.TestClass_testMethod.perfetto-trace

Note: if run from Studio, the file must be adb pull-ed manually, e.g.:

> adb pull /storage/emulated/0/Android/data/androidx.mypackage.test/files/test_data/androidx.mypackage.TestClass_testMethod.trace

You can check logcat for messages tagged "PerfettoCapture:" for the path of each perfetto trace.

> adb pull /storage/emulated/0/Android/data/mypackage.test/files/PerfettoCaptureTest.trace

Summary

Public constructors

Add this rule to record a Perfetto trace for each test on Q+ devices.

Public methods
Statement
apply(base: Statement, description: Description)

Public constructors

PerfettoRule

PerfettoRule()

Add this rule to record a Perfetto trace for each test on Q+ devices.

Relies on either AGP's additionalTestOutputDir copying, or (in Jetpack CI), additionalTestOutputFile_*** copying.

When invoked locally with Gradle, file will be copied to host path like the following:

out/androidx/benchmark/benchmark-macro/build/outputs/connected_android_test_additional_output/debugAndroidTest/connected/<deviceName>/androidx.mypackage.TestClass_testMethod.perfetto-trace

Note: if run from Studio, the file must be adb pull-ed manually, e.g.:

> adb pull /storage/emulated/0/Android/data/androidx.mypackage.test/files/test_data/androidx.mypackage.TestClass_testMethod.trace

You can check logcat for messages tagged "PerfettoCapture:" for the path of each perfetto trace.

> adb pull /storage/emulated/0/Android/data/mypackage.test/files/PerfettoCaptureTest.trace

Public methods

apply

fun apply(
    base: Statement,
    description: Description
): Statement