mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 16:27:06 +05:30
benchmark: init
This commit is contained in:
parent
d8d43a4c88
commit
a66a915e16
12 changed files with 189 additions and 1 deletions
6
benchmark/src/main/AndroidManifest.xml
Normal file
6
benchmark/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<queries>
|
||||
<package android:name="dev.msfjarvis.claw.android" />
|
||||
</queries>
|
||||
</manifest>
|
|
@ -0,0 +1,36 @@
|
|||
package dev.msfjarvis.claw.benchmark
|
||||
|
||||
import androidx.benchmark.macro.BaselineProfileMode
|
||||
import androidx.benchmark.macro.CompilationMode
|
||||
import androidx.benchmark.macro.StartupMode
|
||||
import androidx.benchmark.macro.StartupTimingMetric
|
||||
import androidx.benchmark.macro.junit4.MacrobenchmarkRule
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
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 = PACKAGE_NAME,
|
||||
metrics = listOf(StartupTimingMetric()),
|
||||
iterations = 10,
|
||||
startupMode = StartupMode.COLD,
|
||||
compilationMode = compilationMode
|
||||
) {
|
||||
pressHome()
|
||||
startActivityAndWait()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package dev.msfjarvis.claw.benchmark
|
||||
|
||||
import androidx.benchmark.macro.ExperimentalBaselineProfilesApi
|
||||
import androidx.benchmark.macro.junit4.BaselineProfileRule
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
@ExperimentalBaselineProfilesApi
|
||||
class BaselineProfileGenerator {
|
||||
@get:Rule val baselineProfileRule = BaselineProfileRule()
|
||||
private lateinit var device: UiDevice
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
val instrumentation = InstrumentationRegistry.getInstrumentation()
|
||||
device = UiDevice.getInstance(instrumentation)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun startup() =
|
||||
baselineProfileRule.collectBaselineProfile(packageName = PACKAGE_NAME) {
|
||||
tapNavigationDestinations(device)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package dev.msfjarvis.claw.benchmark
|
||||
|
||||
import androidx.benchmark.macro.MacrobenchmarkScope
|
||||
import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
|
||||
const val PACKAGE_NAME = "dev.msfjarvis.claw.android"
|
||||
|
||||
fun MacrobenchmarkScope.tapNavigationDestinations(device: UiDevice) {
|
||||
startActivityAndWait()
|
||||
device.run {
|
||||
listOf("HOTTEST", "NEWEST", "SAVED").forEach { desc ->
|
||||
findObject(By.desc(desc)).click()
|
||||
waitForIdle()
|
||||
}
|
||||
}
|
||||
device.waitForIdle()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue