Android support generate baseline profile to improve performance. By using micro benchmark to interact with UI to get something on screen.
Docs here: https://developer.android.com/topic/performance/benchmarking/macrobenchmark-overview
https://developer.android.com/topic/performance/baselineprofiles/create-baselineprofile
But by using function startActivityAndAwait i only can open login screen, so I could not interact on private screen (logged in screen). I am using firebase auth for login function.
@LargeTest
@RunWith(AndroidJUnit4::class)
class SampleStartupBenchmark {
@get:Rule
val benchmarkRule = MacrobenchmarkRule()
@Test
fun startup() = benchmarkRule.measureRepeated(
packageName = TARGET_PACKAGE,
metrics = listOf(StartupTimingMetric()),
iterations = DEFAULT_ITERATIONS,
setupBlock = {
// Press home button before each run to ensure the starting activity isn't visible.
pressHome()
}
) {
// starts default launch activity
startActivityAndWait()
}
}
The question is how to interact with private screen to generate expecting baseline profile file?
Not sure another ways but I have to have a login step.
Main function
Login function
Some helpers
Hope this help someone!