代码优化
This commit is contained in:
12 files changed
+301
-147
No files matched your search
@@ -44,21 +44,19 @@ class StartupBenchmarks {
|
||||
val rule = MacrobenchmarkRule()
|
||||
|
||||
@Test
|
||||
fun startupCompilationNone() =
|
||||
benchmark(CompilationMode.None())
|
||||
fun startupCompilationNone() = benchmark(CompilationMode.None())
|
||||
|
||||
@Test
|
||||
fun startupCompilationBaselineProfiles() =
|
||||
benchmark(CompilationMode.Partial(BaselineProfileMode.Require))
|
||||
|
||||
private fun benchmark(compilationMode: CompilationMode) {
|
||||
// The application id for the running build variant is read from the instrumentation arguments.
|
||||
val packageName = InstrumentationRegistry.getArguments().getString("targetAppId")
|
||||
?: "io.legado.app"
|
||||
|
||||
rule.measureRepeated(
|
||||
packageName = packageName,
|
||||
metrics = listOf(StartupTimingMetric(), FrameTimingMetric()),
|
||||
metrics = listOf(StartupTimingMetric()),
|
||||
compilationMode = compilationMode,
|
||||
startupMode = StartupMode.COLD,
|
||||
iterations = 3,
|
||||
@@ -67,18 +65,6 @@ class StartupBenchmarks {
|
||||
},
|
||||
measureBlock = {
|
||||
startActivityAndWait()
|
||||
|
||||
// 等待书架列表加载完成
|
||||
// 我们在 BookshelfScreen 中添加了 testTag("bookshelf_list")
|
||||
device.wait(Until.hasObject(By.res(packageName, "bookshelf_list")), 10000)
|
||||
|
||||
// 模拟交互:在书架上进行滑动,以确保 Profile 捕获到列表渲染和图片加载的路径
|
||||
val bookshelfList = device.findObject(By.res(packageName, "bookshelf_list"))
|
||||
bookshelfList?.apply {
|
||||
setGestureMargin(device.displayWidth / 10)
|
||||
fling(Direction.DOWN)
|
||||
device.waitForIdle()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user