I configured a benchmark module and created a baseline profile for the project and saved it in the app according to the instructions here https://developer.android.com/studio/profile/baselineprofiles.
I've also added the benchmark:
@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 = "com.example.app",
metrics = listOf(StartupTimingMetric()),
iterations = 10,
startupMode = StartupMode.COLD,
compilationMode = compilationMode
) {
pressHome()
startActivityAndWait()
}
}
}
startupBaselineProfile()
test fails with an exception "Baseline profiles aren't supported on this device version". I tried to run it on different Pixel and Samsung devices with the latest Android version, but the same exception is thrown everywhere.
Do these baseline profiles wok at all?