TP-12345 | spotless | move to exclusion rule (#10724)
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright © 2024 by Navi Technologies Limited
|
||||
* * All rights reserved. Strictly confidential
|
||||
*
|
||||
*/
|
||||
|
||||
package com.naviapp.benchmark.baselineprofile
|
||||
|
||||
import android.os.Build
|
||||
@@ -11,16 +18,12 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class HomePageScrollBaselineProfile {
|
||||
@RequiresApi(Build.VERSION_CODES.P)
|
||||
@get:Rule
|
||||
val baselineProfileRule = BaselineProfileRule()
|
||||
@RequiresApi(Build.VERSION_CODES.P) @get:Rule val baselineProfileRule = BaselineProfileRule()
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.P)
|
||||
@Test
|
||||
fun generate() =
|
||||
baselineProfileRule.collect(
|
||||
PACKAGE_NAME
|
||||
) {
|
||||
baselineProfileRule.collect(PACKAGE_NAME) {
|
||||
startActivityAndAllowNotifications()
|
||||
waitForHomePage()
|
||||
scrollHomePage()
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright © 2024 by Navi Technologies Limited
|
||||
* * All rights reserved. Strictly confidential
|
||||
*
|
||||
*/
|
||||
|
||||
package com.naviapp.benchmark.home
|
||||
|
||||
import androidx.benchmark.macro.CompilationMode
|
||||
@@ -13,33 +20,29 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class HomePageScrollBenchmark {
|
||||
@get:Rule
|
||||
val benchmarkRule = MacrobenchmarkRule()
|
||||
@get:Rule val benchmarkRule = MacrobenchmarkRule()
|
||||
|
||||
@Test
|
||||
fun scrollHomeCompilationNone() = scrollHomePage(CompilationMode.None())
|
||||
@Test fun scrollHomeCompilationNone() = scrollHomePage(CompilationMode.None())
|
||||
|
||||
@Test
|
||||
fun scrollHomeCompilationBaselineProfile() = scrollHomePage(CompilationMode.Partial())
|
||||
@Test fun scrollHomeCompilationBaselineProfile() = scrollHomePage(CompilationMode.Partial())
|
||||
|
||||
@Test
|
||||
fun scrollHomeCompilationFull() = scrollHomePage(CompilationMode.Full())
|
||||
@Test fun scrollHomeCompilationFull() = scrollHomePage(CompilationMode.Full())
|
||||
|
||||
private fun scrollHomePage(compilationMode: CompilationMode) = benchmarkRule.measureRepeated(
|
||||
packageName = PACKAGE_NAME,
|
||||
metrics = listOf(FrameTimingMetric()),
|
||||
iterations = 10,
|
||||
startupMode = StartupMode.WARM,
|
||||
compilationMode = compilationMode,
|
||||
setupBlock = {
|
||||
pressHome()
|
||||
startActivityAndAllowNotifications()
|
||||
private fun scrollHomePage(compilationMode: CompilationMode) =
|
||||
benchmarkRule.measureRepeated(
|
||||
packageName = PACKAGE_NAME,
|
||||
metrics = listOf(FrameTimingMetric()),
|
||||
iterations = 10,
|
||||
startupMode = StartupMode.WARM,
|
||||
compilationMode = compilationMode,
|
||||
setupBlock = {
|
||||
pressHome()
|
||||
startActivityAndAllowNotifications()
|
||||
}
|
||||
) {
|
||||
waitForHomePage()
|
||||
scrollHomePage()
|
||||
}
|
||||
) {
|
||||
waitForHomePage()
|
||||
scrollHomePage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright © 2024 by Navi Technologies Limited
|
||||
* * All rights reserved. Strictly confidential
|
||||
*
|
||||
*/
|
||||
|
||||
package com.naviapp.benchmark.startup
|
||||
|
||||
import androidx.benchmark.macro.BaselineProfileMode.Disable
|
||||
@@ -17,36 +24,35 @@ import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4ClassRunner::class)
|
||||
class StartupBenchmark {
|
||||
@get:Rule
|
||||
val benchmarkRule = MacrobenchmarkRule()
|
||||
@get:Rule val benchmarkRule = MacrobenchmarkRule()
|
||||
|
||||
@Test fun startupWithoutPreCompilation() = startup(CompilationMode.None())
|
||||
|
||||
@Test
|
||||
fun startupWithoutPreCompilation() = startup(CompilationMode.None())
|
||||
|
||||
@Test
|
||||
fun startupWithPartialCompilationAndDisabledBaselineProfile() = startup(
|
||||
CompilationMode.Partial(baselineProfileMode = Disable, warmupIterations = 1),
|
||||
)
|
||||
fun startupWithPartialCompilationAndDisabledBaselineProfile() =
|
||||
startup(
|
||||
CompilationMode.Partial(baselineProfileMode = Disable, warmupIterations = 1),
|
||||
)
|
||||
|
||||
@Test
|
||||
fun startupPrecompiledWithBaselineProfile() =
|
||||
startup(CompilationMode.Partial(baselineProfileMode = Require))
|
||||
|
||||
@Test
|
||||
fun startupFullyPrecompiled() = startup(CompilationMode.Full())
|
||||
@Test fun startupFullyPrecompiled() = startup(CompilationMode.Full())
|
||||
|
||||
private fun startup(compilationMode: CompilationMode) = benchmarkRule.measureRepeated(
|
||||
packageName = PACKAGE_NAME,
|
||||
metrics = listOf(StartupTimingMetric()),
|
||||
compilationMode = compilationMode,
|
||||
iterations = 5,
|
||||
startupMode = COLD,
|
||||
setupBlock = {
|
||||
pressHome()
|
||||
allowNotifications()
|
||||
},
|
||||
) {
|
||||
startActivityAndAllowNotifications()
|
||||
waitForHomePageLoad()
|
||||
}
|
||||
private fun startup(compilationMode: CompilationMode) =
|
||||
benchmarkRule.measureRepeated(
|
||||
packageName = PACKAGE_NAME,
|
||||
metrics = listOf(StartupTimingMetric()),
|
||||
compilationMode = compilationMode,
|
||||
iterations = 5,
|
||||
startupMode = COLD,
|
||||
setupBlock = {
|
||||
pressHome()
|
||||
allowNotifications()
|
||||
},
|
||||
) {
|
||||
startActivityAndAllowNotifications()
|
||||
waitForHomePageLoad()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright © 2024 by Navi Technologies Limited
|
||||
* * All rights reserved. Strictly confidential
|
||||
*
|
||||
*/
|
||||
|
||||
package com.naviapp.benchmark.utils
|
||||
|
||||
import android.Manifest.permission
|
||||
@@ -15,4 +22,4 @@ fun MacrobenchmarkScope.allowNotifications() {
|
||||
fun MacrobenchmarkScope.startActivityAndAllowNotifications() {
|
||||
startActivityAndWait()
|
||||
allowNotifications()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright © 2024 by Navi Technologies Limited
|
||||
* * All rights reserved. Strictly confidential
|
||||
*
|
||||
*/
|
||||
|
||||
package com.naviapp.benchmark.utils
|
||||
|
||||
import androidx.benchmark.macro.MacrobenchmarkScope
|
||||
@@ -8,35 +15,34 @@ import androidx.test.uiautomator.Until
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
fun MacrobenchmarkScope.waitForHomePage() {
|
||||
device.wait(
|
||||
Until.hasObject(By.clazz(HOME_PAGE_CLASS_NAME)), TimeUnit.SECONDS.toMillis(50)
|
||||
)
|
||||
device.wait(Until.hasObject(By.clazz(HOME_PAGE_CLASS_NAME)), TimeUnit.SECONDS.toMillis(50))
|
||||
}
|
||||
|
||||
fun MacrobenchmarkScope.scrollHomePage() {
|
||||
val list = device.waitAndFindObject(By.res("homeScreenWidgetsList"), TimeUnit.SECONDS.toMillis(10))
|
||||
val list =
|
||||
device.waitAndFindObject(By.res("homeScreenWidgetsList"), TimeUnit.SECONDS.toMillis(10))
|
||||
device.flingElementDownUp(list)
|
||||
}
|
||||
|
||||
fun MacrobenchmarkScope.waitForHomePageLoad() {
|
||||
device.wait(
|
||||
Until.hasObject(By.clazz(HOME_PAGE_CLASS_NAME)), TimeUnit.SECONDS.toMillis(50)
|
||||
)
|
||||
val list = device.waitAndFindObject(
|
||||
By.res("homeScreenWidgetsList"), TimeUnit.SECONDS.toMillis(10)
|
||||
)
|
||||
device.wait(Until.hasObject(By.clazz(HOME_PAGE_CLASS_NAME)), TimeUnit.SECONDS.toMillis(50))
|
||||
val list =
|
||||
device.waitAndFindObject(By.res("homeScreenWidgetsList"), TimeUnit.SECONDS.toMillis(10))
|
||||
list.wait(untilHasChildren(), 60_000)
|
||||
}
|
||||
|
||||
fun untilHasChildren(
|
||||
childCount: Int = 1,
|
||||
op: HasChildrenOp = HasChildrenOp.AT_LEAST,
|
||||
): UiObject2Condition<Boolean> = object : UiObject2Condition<Boolean>() {
|
||||
override fun apply(element: UiObject2): Boolean = when (op) {
|
||||
HasChildrenOp.AT_LEAST -> element.childCount >= childCount
|
||||
HasChildrenOp.EXACTLY -> element.childCount == childCount
|
||||
HasChildrenOp.AT_MOST -> element.childCount <= childCount
|
||||
): UiObject2Condition<Boolean> =
|
||||
object : UiObject2Condition<Boolean>() {
|
||||
override fun apply(element: UiObject2): Boolean =
|
||||
when (op) {
|
||||
HasChildrenOp.AT_LEAST -> element.childCount >= childCount
|
||||
HasChildrenOp.EXACTLY -> element.childCount == childCount
|
||||
HasChildrenOp.AT_MOST -> element.childCount <= childCount
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum class HasChildrenOp {
|
||||
AT_LEAST,
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright © 2024 by Navi Technologies Limited
|
||||
* * All rights reserved. Strictly confidential
|
||||
*
|
||||
*/
|
||||
|
||||
package com.naviapp.benchmark.utils
|
||||
|
||||
import androidx.test.uiautomator.BySelector
|
||||
@@ -6,9 +13,7 @@ import androidx.test.uiautomator.UiDevice
|
||||
import androidx.test.uiautomator.UiObject2
|
||||
import androidx.test.uiautomator.Until
|
||||
|
||||
val PACKAGE_NAME = buildString {
|
||||
append("com.naviapp.dev")
|
||||
}
|
||||
val PACKAGE_NAME = buildString { append("com.naviapp.dev") }
|
||||
|
||||
val HOME_PAGE_CLASS_NAME = buildString {
|
||||
append("com.naviapp.home.compose.activity.HomePageActivity")
|
||||
|
||||
Reference in New Issue
Block a user