Skip to content

Commit 92adf7e

Browse files
committed
feat(perf): add benchmark build type for accurate startup measurements
Add non-debuggable 'benchmark' build type to the app, allowing the macrobenchmark module to measure startup without debuggable overhead and with baseline profile installation support.
1 parent dc96848 commit 92adf7e

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

apps/flipcash/app/build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ android {
8484
)
8585
}
8686
}
87+
create("benchmark") {
88+
initWith(getByName("debug"))
89+
isDebuggable = false
90+
signingConfig = signingConfigs.getByName("contributors")
91+
matchingFallbacks += listOf("debug")
92+
}
8793
}
8894

8995
compileOptions {

apps/flipcash/benchmark/build.gradle.kts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ android {
1212
minSdk = 29
1313
targetSdk = libs.versions.android.targetSdk.get().toInt()
1414
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
15-
testInstrumentationRunnerArguments["androidx.benchmark.suppressErrors"] =
16-
"EMULATOR,DEBUGGABLE"
15+
testInstrumentationRunnerArguments["androidx.benchmark.suppressErrors"] = "EMULATOR"
1716
}
1817

1918
signingConfigs {
@@ -26,8 +25,10 @@ android {
2625
}
2726

2827
buildTypes {
29-
debug {
28+
create("benchmark") {
29+
isDebuggable = true
3030
signingConfig = signingConfigs.getByName("contributors")
31+
matchingFallbacks += listOf("debug")
3132
}
3233
}
3334

apps/flipcash/benchmark/src/main/kotlin/com/flipcash/benchmark/StartupBenchmark.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ class StartupBenchmark {
2929
)
3030
)
3131

32-
// Requires a non-debuggable (release/benchmark) build to install the baseline profile.
33-
// Add a 'benchmark' buildType to the app module to enable this test.
34-
// @Test
35-
// fun startupBaselineProfile() = benchmark(
36-
// CompilationMode.Partial(baselineProfileMode = BaselineProfileMode.Require)
37-
// )
32+
@Test
33+
fun startupBaselineProfile() = benchmark(
34+
CompilationMode.Partial(baselineProfileMode = BaselineProfileMode.Require)
35+
)
3836

3937
@Test
4038
fun startupFullCompilation() = benchmark(CompilationMode.Full())

0 commit comments

Comments
 (0)