PerfettoRule

@RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP_PREFIX]) public final class 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 "PerfettoRule:" for the path of each perfetto trace.

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

Summary

Public constructors

Public methods

@NonNull Statement
apply(@NonNull Statement base, @NonNull Description description)

Public constructors

PerfettoRule

public final PerfettoRule()

Public methods

apply

@NonNull
public Statement apply(@NonNull Statement base, @NonNull Description description)