Skip to content

Commit ce59136

Browse files
committed
refactor: mapFling and add search functionality
1 parent ce6827b commit ce59136

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

benchmarks/src/main/kotlin/com/espressodev/benchmarks/map/MapActions.kt

+23-12
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,32 @@ fun MacrobenchmarkScope.mapWaitForContent() {
1313

1414
fun MacrobenchmarkScope.mapFling() {
1515
val mapScreen = device.findObject(By.res("map:MapScreen"))
16-
repeat(20) {
17-
device.flingElement(mapScreen, Direction.DOWN)
18-
}
19-
device.waitForIdle(4000)
20-
repeat(20) {
21-
device.flingElement(mapScreen, Direction.LEFT)
16+
17+
fun flingMap(direction: Direction, repetitions: Int, delay: Long) {
18+
repeat(repetitions) {
19+
device.flingElement(mapScreen, direction)
20+
}
21+
device.waitForIdle(delay)
2222
}
23-
device.waitForIdle(4000)
24-
repeat(20) {
25-
device.flingElement(mapScreen, Direction.UP)
23+
24+
val directions = listOf(Direction.DOWN, Direction.LEFT, Direction.UP, Direction.RIGHT)
25+
directions.forEach { direction ->
26+
flingMap(direction, 5, 100)
2627
}
27-
device.waitForIdle(4000)
28-
repeat(20) {
29-
device.flingElement(mapScreen, Direction.RIGHT)
28+
}
29+
30+
fun MacrobenchmarkScope.search() {
31+
val searchBar = device.findObject(By.res("map:SearchBar"))
32+
val searchBarSearchIcon = device.findObject(By.res("map:searchBarSearchIcon"))
33+
if (searchBar.isClickable && searchBar.isFocusable) {
34+
searchBar.click()
35+
searchBar.text = ""
36+
searchBar.text = "New York"
3037
}
38+
39+
device.waitForIdle()
40+
searchBarSearchIcon.click()
41+
device.wait(Until.hasObject(By.text("Explore more with AI")), 10_000)
3142
}
3243

3344
fun UiDevice.flingElement(element: UiObject2, direction: Direction) {

benchmarks/src/main/kotlin/com/espressodev/benchmarks/map/SwipeGoogleMapBenchmark.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class SwipeGoogleMapBenchmark {
2020
fun swipeGoogleMapCompilationNone() = swipeGoogleMap(CompilationMode.None())
2121

2222
@Test
23-
fun swipeGoogleMapCompilationBaselineProfile() = swipeGoogleMap(CompilationMode.Partial())
23+
fun swipeGoogleMapCompilationBaselineProfile() = swipeGoogleMap(CompilationMode.Partial(warmupIterations = 1))
2424

2525
private fun swipeGoogleMap(compilationMode: CompilationMode) = benchmarkRule.measureRepeated(
2626
packageName = PACKAGE_NAME,
@@ -31,12 +31,13 @@ class SwipeGoogleMapBenchmark {
3131
setupBlock = {
3232
pressHome()
3333
startActivityAndWait()
34-
// We use dot notation because it can skip auth phase
34+
// We use question mark because it can skip auth phase
3535
device.findObject(By.text("Continue with Google"))?.click()
3636
device.waitForIdle()
3737
}
3838
) {
3939
mapWaitForContent()
4040
mapFling()
41+
search()
4142
}
4243
}

benchmarks/src/main/kotlin/com/espressodev/benchmarks/startup/StartupBenchmark.kt

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package com.espressodev.benchmarks.startup
22

3-
import androidx.benchmark.macro.BaselineProfileMode
43
import androidx.benchmark.macro.CompilationMode
54
import androidx.benchmark.macro.StartupMode
65
import androidx.benchmark.macro.StartupTimingMetric
76
import androidx.benchmark.macro.junit4.MacrobenchmarkRule
87
import androidx.test.ext.junit.runners.AndroidJUnit4
98
import androidx.test.filters.LargeTest
9+
import androidx.test.uiautomator.By
1010
import com.espressodev.benchmarks.PACKAGE_NAME
1111
import com.espressodev.benchmarks.map.mapFling
1212
import com.espressodev.benchmarks.map.mapWaitForContent
13-
13+
import com.espressodev.benchmarks.map.search
1414
import org.junit.Rule
1515
import org.junit.Test
1616
import org.junit.runner.RunWith
@@ -46,32 +46,30 @@ class StartupBenchmark {
4646
fun startupCompilationNone() =
4747
benchmark(CompilationMode.None())
4848

49-
@Test
50-
fun startupWithPartialCompilationAndDisabledBaselineProfile() = benchmark(
51-
CompilationMode.Partial(baselineProfileMode = BaselineProfileMode.Disable, warmupIterations = 1),
52-
)
53-
5449
@Test
5550
fun startupFullyPrecompiled() = benchmark(CompilationMode.Full())
5651

5752
@Test
5853
fun startupCompilationBaselineProfiles() =
59-
benchmark(CompilationMode.Partial(BaselineProfileMode.Require))
54+
benchmark(CompilationMode.Partial(warmupIterations = 1))
6055

6156
private fun benchmark(compilationMode: CompilationMode) {
6257
rule.measureRepeated(
6358
packageName = PACKAGE_NAME,
6459
metrics = listOf(StartupTimingMetric()),
6560
compilationMode = compilationMode,
6661
startupMode = StartupMode.COLD,
67-
iterations = 10,
62+
iterations = 5,
6863
setupBlock = {
6964
pressHome()
7065
},
7166
measureBlock = {
7267
startActivityAndWait()
68+
device.findObject(By.text("Continue with Google"))?.click()
69+
device.waitForIdle()
7370
mapWaitForContent()
7471
mapFling()
72+
search()
7573
}
7674
)
7775
}

0 commit comments

Comments
 (0)