Skip to content

Instantly share code, notes, and snippets.

@skydoves
Created November 10, 2023 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skydoves/89b15a25216aa963b02cb64814763794 to your computer and use it in GitHub Desktop.
Save skydoves/89b15a25216aa963b02cb64814763794 to your computer and use it in GitHub Desktop.
startup_benchmarks
class StartupBenchmarks {
@get:Rule
val rule = MacrobenchmarkRule()
@Test
fun startupCompilationNone() =
benchmark(CompilationMode.None())
@Test
fun startupCompilationBaselineProfiles() =
benchmark(CompilationMode.Partial(BaselineProfileMode.Require))
private fun benchmark(compilationMode: CompilationMode) {
rule.measureRepeated(
packageName = "YOUR_APPLICATION_PACKAGE_NAME",
metrics = listOf(StartupTimingMetric()),
compilationMode = compilationMode,
startupMode = StartupMode.COLD,
iterations = 10,
setupBlock = {
pressHome()
},
measureBlock = {
startActivityAndWait()
device.waitForIdle()
// app sceniarios
},
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment