MacrobenchmarkScope

public final class MacrobenchmarkScope


Provides access to common operations in app automation, such as killing the app, or navigating home.

Summary

Public fields

final @NonNull UiDevice

Get the UiDevice instance, to use in reading target app UI state, or interacting with the UI via touches, scrolls, or other inputs.

final Integer

Current Macrobenchmark measurement iteration, or null if measurement is not yet enabled.

final @NonNull String

Package name of the app being tested.

Public constructors

MacrobenchmarkScope(String packageName, boolean launchWithClearTask)

Public methods

final void

Drop Kernel's in-memory cache of disk pages.

final void

Force-stop the process being measured.

final void
pressHome(long delayDurationMs)

Perform a home button click.

final void
startActivityAndWait(Function1<IntentUnit> block)

Start an activity, by default the default launch of the package, and wait until its launch completes.

final void

Start an activity with the provided intent, and wait until its launch completes.

Public fields

device

public final @NonNull UiDevice device

Get the UiDevice instance, to use in reading target app UI state, or interacting with the UI via touches, scrolls, or other inputs.

Convenience for UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())

iteration

public final Integer iteration

Current Macrobenchmark measurement iteration, or null if measurement is not yet enabled.

Non-measurement iterations can occur due to warmup a CompilationMode, or prior to the first iteration for StartupMode.WARM or StartupMode.HOT, to create the Process or Activity ahead of time.

packageName

public final @NonNull String packageName

Package name of the app being tested.

Public constructors

MacrobenchmarkScope

public final MacrobenchmarkScope(String packageName, boolean launchWithClearTask)

Public methods

dropKernelPageCache

public final void dropKernelPageCache()

Drop Kernel's in-memory cache of disk pages.

Enables measuring disk-based startup cost, without simply accessing cache of disk data held in memory, such as during