[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-01 (世界標準時間)。"],[],[],null,["# Macrobenchmark instrumentation arguments\n\nConfigure the behavior of the library with the following instrumentation\narguments. You can either add these to your Gradle configuration or apply them\ndirectly when running instrumentation from the command line. To set these\narguments for all Android Studio and command line test runs, add them to\n`testInstrumentationRunnerArguments`: \n\n android {\n defaultConfig {\n // ...\n testInstrumentationRunnerArguments[\"androidx.benchmark.dryRunMode.enable\"] = \"true\"\n }\n }\n\nYou can also set up instrumentation arguments when running the benchmarks from\nAndroid Studio. To change the arguments, do the following: \n1. Edit the run configuration by clicking **Edit** and then clicking the configuration. **Figure 1.** Edit the run configuration.\n2. Edit the instrumentation arguments by clicking more_horiz **More** by **Instrumentation arguments** . **Figure 2.** Edit the instrumentation arguments.\n3. Add the required instrumentation argument by clicking add **Add** under **Instrumentation\n Extra Params** . **Figure 3.** Add the required instrumentation argument.\n\n\u003cbr /\u003e\n\nIf you're running the macrobenchmark from the command line, use `-P\nandroid.testInstrumentationRunnerArguments.[name of the argument]`: \n\n ./gradlew :benchmark:connectedAndroidTest -P android.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile\n\nIf you're invoking the `am instrument` command directly (which may be the case\nin CI testing environments), pass the argument to `am instrument` with `-e`: \n\n adb shell am instrument -e androidx.benchmark.enabledRules BaselineProfile -w com.example.macrobenchmark/androidx.test.runner.AndroidJUnitRunner\n\nFor more information about configuring benchmarks in CI, see\n[Benchmarking in CI](/topic/performance/benchmarking/benchmarking-in-ci#install-and)\n\nandroidx.benchmark.compilation.enabled\n--------------------------------------\n\nLets you disable compilation between each iteration of the benchmark. By\ndefault, the target application is re-installed and re-compiled between each\nbenchmark, to respect the [`CompilationMode`](/reference/kotlin/androidx/benchmark/macro/CompilationMode) passed into\n[`measureRepeated`](/reference/kotlin/androidx/benchmark/macro/junit4/MacrobenchmarkRule#measurerepeated). Disabling this lets you to skip both\nreinstall and compilation if, for example, you want to fully compile the target\napp once before running the test suite and run all benchmarks against that fully\ncompiled target.\n\n- **Argument type:** boolean\n- **Defaults to:** `true`\n\nandroidx.benchmark.dryRunMode.enable\n------------------------------------\n\nLets you run benchmarks in a single loop to verify whether they work properly.\nYou can use it with regular tests as part of verification.\n\n- **Argument type:** boolean\n- **Defaults to:** `false`\n\nandroidx.benchmark.enabledRules\n-------------------------------\n\nAllows filtering runs to just one type of test: Baseline Profile generation or\nMacrobenchmark test. Comma-separated lists are also supported.\n\n- **Argument type**: string\n- Available options:\n - `Macrobenchmark`\n - `BaselineProfile`\n- **Defaults to:** Not specified\n\nandroidx.benchmark.fullTracing.enable\n-------------------------------------\n\n| **Note:** This argument was previously named `perfettoSdkTracing`.\n\nEnables `androidx.tracing.perfetto` tracepoints such as Jetpack Compose\ncomposition tracing.\n\nYou need to set up your project to be able to capture composition tracing\nfrom benchmarks. For more information, see [Capture a trace with Jetpack\nMacrobenchmark](/jetpack/compose/tooling/tracing#macrobenchmark).\n\n- **Argument type**: boolean\n- **Defaults to** : `false`\n\nandroidx.benchmark.killExistingPerfettoRecordings\n-------------------------------------------------\n\nBenchmark by default kills any existing Perfetto (System Trace) recordings when\nstarting a new trace to reduce interference. To disable this behavior, pass\n`false`.\n\n- **Argument type:** boolean\n- **Defaults to:** `true`\n\nandroidx.benchmark.profiling.mode\n---------------------------------\n\nAllows capturing trace files while running the benchmarks. The available options\nare the same as those for the Microbenchmark library---for more information, see\nthe descriptions at\n[Profile a Microbenchmark](/topic/performance/benchmarking/microbenchmark-profile).\n\n- **Argument type:** string\n- Available options:\n - `MethodTracing`\n - `StackSampling`\n - `None`\n- **Defaults to:** `None`\n\nandroidx.benchmark.startupProfiles.enable\n-----------------------------------------\n\nLets you disable the generation of startup profiles during benchmarking.\n\n- **Argument type**: boolean\n- **Defaults to:** `true`\n\nandroidx.benchmark.suppressErrors\n---------------------------------\n\nAccepts comma-separated list of errors to turn into warnings.\n\n- **Argument type**: list of strings\n- Available options:\n\n - `DEBUGGABLE`\n\n The `DEBUGGABLE` error indicates that the target package is running with\n `debuggable=true` in its manifest, which drastically reduces runtime\n performance to support debugging features. To avoid this error, run\n benchmarks with `debuggable=false`. The debuggable argument affects\n execution speed in ways that mean benchmark improvements might not carry\n over to a real user's experience or might regress release performance.\n - `LOW-BATTERY`\n\n When battery is low, devices often reduce performance to save remaining\n battery, for example by disabling big cores. This occurs even when the\n devices are plugged in. Only suppress this error if you are deliberately\n profiling the app with reduced performance.\n - `EMULATOR`\n\n The `EMULATOR` error tells you that the benchmark is running on an\n emulator, which isn't representative of real user devices. Emulator\n benchmark improvements might not carry over to a real user's experience\n or might regress real device performance. You should use a physical\n device to benchmark instead. Suppress this error with extreme caution.\n - `NOT-PROFILEABLE`\n\n Target package `$packageName` is running without\n `\u003cprofileable shell=true\u003e`. Profileable is required on Android 10 and 11\n to let Macrobenchmark capture detailed trace information from the target\n process, such as system tracing sections defined in the app or\n libraries. Suppress this error with extreme caution.\n - `METHOD-TRACING-ENABLED`\n\n The Macrobenchmark run for the app being benchmarked has method tracing\n enabled. This causes the VM to run slower than usual, so only consider\n the metrics from the trace files in relative terms---for example,\n comparing how fast the first run is to the second run. Suppressing this\n error can result in inaccurate results if you compare benchmarks for\n builds with different method tracing options.\n- **Defaults to**: an empty list\n\nadditionalTestOutputDir\n-----------------------\n\nConfigures where JSON benchmark reports and profiling results are saved on\ndevice.\n\n- **Argument type:** path string\n- **Defaults to:** test APK's external directory\n\nlistener\n--------\n\nYou might get inconsistent benchmark results if unrelated background work gets\nexecuted while the benchmark is running.\n\nTo disable background work during benchmarking set the `listener`\ninstrumentation argument type to\n`androidx.benchmark.junit4.SideEffectRunListener`.\n\n- **Argument type:** string\n- Available options:\n - `androidx.benchmark.junit4.SideEffectRunListener`\n- **Defaults to:** not specified\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Microbenchmark Instrumentation Arguments](/topic/performance/benchmarking/microbenchmark-instrumentation-args)\n- [Create Baseline Profiles](/topic/performance/baselineprofiles/create-baselineprofile)\n- [JankStats Library](/topic/performance/jankstats)"]]