Last active
September 6, 2022 08:56
-
-
Save bastionkid/4ace15312c1c6cd76cb107a00a80e0cb to your computer and use it in GitHub Desktop.
App startup timing test with and without Baseline Profiles
This file contains 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
@RunWith(AndroidJUnit4::class) | |
class BaselineProfileBenchmark { | |
@get:Rule | |
val benchmarkRule = MacrobenchmarkRule() | |
@Test | |
fun startupNoCompilation() { | |
startup(CompilationMode.None()) | |
} | |
@Test | |
fun startupBaselineProfile() { | |
startup(CompilationMode.Partial( | |
baselineProfileMode = BaselineProfileMode.Require | |
)) | |
} | |
private fun startup(compilationMode: CompilationMode) { | |
benchmarkRule.measureRepeated( | |
packageName = YOUR_APP_PACKAGE_NAME, | |
metrics = listOf(StartupTimingMetric()), | |
iterations = 10, | |
startupMode = StartupMode.COLD, | |
compilationMode = compilationMode | |
) { // this = MacrobenchmarkScope | |
pressHome() | |
startActivityAndWait() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment