我配置了一个基准模块并为该项目创建了一个基线配置文件,并根据此处的说明将其保存在应用程序中 https://developer.android.com/studio/profile/baselineprofiles .
我还添加了基准:
@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()
测试失败,出现异常“此设备版本不支持基线配置文件”。我尝试在具有最新 Android 版本的不同 Pixel 和 Samsung 设备上运行它,但到处都会抛出相同的异常。这些基线配置文件是否有效?
最佳答案
当前基线配置文件有一些已知问题:
请注意,profileinstaller 可能会添加一个库(例如 jetpack compose),因此请确保将其添加到依赖项中以覆盖版本。
关于android - 此设备版本不支持基线配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71174855/