Microbenchmark instrumentation arguments

Configure the behavior of your benchmarks by specifying different arguments to the instrumentation runner. These can either be applied to your Gradle configuration or added directly when running instrumentation from the command line.

To set up instrumentation arguments when running the benchmarks from Android Studio, do the following:

  1. Edit the run configuration by clicking Edit and selecting the configuration you want to edit.
    Figure 1. Edit the run configuration.
  2. Edit instrumentation arguments by clicking next to the Instrumentation arguments field.
    Figure 2. Edit the instrumentation argument.
  3. Click and add the required instrumentation argument.
    Figure 3. Add the instrumentation argument.


Configures where JSON benchmark reports and profiling results are saved on device.

  • Argument type: file path string
  • Defaults to: test APK's external directory


Lets you run benchmarks in single loop to verify that they work properly. You can use it with regular tests as part of verification.

  • Argument type: boolean
  • Defaults to: false


Overrides time-driven target iteration counts to help ensure a consistent amount of work. This is typically only useful with profiling enabled to help ensure consistent quantity of work is performed within a profiling trace when comparing different implementations or runs. In other scenarios, this likely reduces accuracy or stability of measurements.

  • Argument type: integer
  • Defaults to: not specified


You might get inconsistent benchmark results if unrelated background work gets executed while the benchmark is running.

To disable background work during benchmarking set the listener instrumentation argument type to androidx.benchmark.junit4.SideEffectRunListener.

  • Argument type: string
  • Available options:
    • androidx.benchmark.junit4.SideEffectRunListener
  • Defaults to: not specified


Enables writing the result JSON file to external storage.

  • Argument type: boolean
  • Defaults to: true


Allows capturing trace files while running the benchmarks. See Profile a Microbenchmark for available options.

  • Argument type: string
  • Available options:
    • MethodTracing
    • StackSampling
    • None
  • Defaults to: None


Accepts a comma-separated list of errors to turn into warnings.

  • Argument type: list of strings
  • Available options:
  • Defaults to: an empty list

androidx.benchmark.startupMode.enable (Deprecated)

Reconfigures looping behavior to support benchmarking code during startup. The benchmarks are executed without warmup looping for 10 measurements. To minimize overhead in microbenchmarks, loop averaging is disabled.

  • Argument type: boolean
  • Defaults to: false