Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c1a8186

Browse files
authoredMay 23, 2025
Add benchmark to measure startup time with cleared app data (#6985)
1 parent 6e33cf3 commit c1a8186

File tree

1 file changed

+22
-1
lines changed
  • firebase-sessions/benchmark/src/main/kotlin/com/google/firebase/benchmark/sessions

1 file changed

+22
-1
lines changed
 

‎firebase-sessions/benchmark/src/main/kotlin/com/google/firebase/benchmark/sessions/StartupBenchmark.kt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import androidx.benchmark.macro.StartupMode
2020
import androidx.benchmark.macro.StartupTimingMetric
2121
import androidx.benchmark.macro.junit4.MacrobenchmarkRule
2222
import androidx.test.ext.junit.runners.AndroidJUnit4
23+
import androidx.test.platform.app.InstrumentationRegistry
2324
import org.junit.Rule
2425
import org.junit.Test
2526
import org.junit.runner.RunWith
@@ -31,12 +32,32 @@ class StartupBenchmark {
3132
@Test
3233
fun startup() =
3334
benchmarkRule.measureRepeated(
34-
packageName = "com.google.firebase.testing.sessions",
35+
packageName = PACKAGE_NAME,
3536
metrics = listOf(StartupTimingMetric()),
3637
iterations = 5,
3738
startupMode = StartupMode.COLD,
3839
) {
3940
pressHome()
4041
startActivityAndWait()
4142
}
43+
44+
@Test
45+
fun startup_clearAppData() =
46+
benchmarkRule.measureRepeated(
47+
packageName = PACKAGE_NAME,
48+
metrics = listOf(StartupTimingMetric()),
49+
iterations = 5,
50+
startupMode = StartupMode.COLD,
51+
) {
52+
pressHome()
53+
InstrumentationRegistry.getInstrumentation()
54+
.uiAutomation
55+
.executeShellCommand("pm clear $PACKAGE_NAME")
56+
.close()
57+
startActivityAndWait()
58+
}
59+
60+
private companion object {
61+
const val PACKAGE_NAME = "com.google.firebase.testing.sessions"
62+
}
4263
}

0 commit comments

Comments
 (0)
Please sign in to comment.