Created
January 12, 2026 02:28
-
-
Save maskaravivek/5234993011863ffb2b2c704f927626d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const val TARGET_PACKAGE = "com.circleci.samples.todoapp" | |
| fun MacrobenchmarkRule.measureStartup( | |
| profileCompiled: Boolean, | |
| startupMode: StartupMode, | |
| iterations: Int = 3, | |
| setupIntent: Intent.() -> Unit = {} | |
| ) = measureRepeated( | |
| packageName = TARGET_PACKAGE, | |
| metrics = listOf(StartupTimingMetric()), | |
| compilationMode = if (profileCompiled) { | |
| CompilationMode.SpeedProfile(warmupIterations = 3) | |
| } else { | |
| CompilationMode.None | |
| }, | |
| iterations = iterations, | |
| startupMode = startupMode | |
| ) { | |
| pressHome() | |
| val intent = Intent() | |
| intent.setPackage(TARGET_PACKAGE) | |
| setupIntent(intent) | |
| startActivityAndWait(intent) | |
| } | |
| @LargeTest | |
| @RunWith(Parameterized::class) | |
| class StartupBenchmarks(private val startupMode: StartupMode) { | |
| @get:Rule | |
| val benchmarkRule = MacrobenchmarkRule() | |
| @Test | |
| fun startupMultiple() = benchmarkRule.measureStartup( | |
| profileCompiled = false, | |
| startupMode = startupMode, | |
| iterations = 5 | |
| ) { | |
| action = "com.circleci.samples.target.STARTUP_ACTIVITY" | |
| } | |
| companion object { | |
| @Parameterized.Parameters(name = "mode={0}") | |
| @JvmStatic | |
| fun parameters(): List<Array<Any>> { | |
| return listOf(StartupMode.COLD, StartupMode.WARM, StartupMode.HOT) | |
| .map { arrayOf(it) } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment