Skip to content

Commit a257760

Browse files
Runtime Optimization: Process all actions possible within 30ms frame rate
Runtime will keep processing actions that do not produce output until the frame timeout of 30ms. This is an abitrary value and (TODO) we should connect it with the Choreographer frame clock in similar way to how molecule does it with the AndroidUiDispatcher.Main and its frame clock. Tests are modified for when using the optimized runtime in order to wait past the timeout. We add expect fun currentTimeMillis() to the common code to get epoch millis on all platforms.
1 parent a0ed706 commit a257760

File tree

44 files changed

+1869
-439
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1869
-439
lines changed

.github/workflows/kotlin.yml

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs :
9595
ios-tests :
9696
name : iOS Tests
9797
runs-on : macos-latest
98-
timeout-minutes : 20
98+
timeout-minutes : 30
9999
steps :
100100
- uses : actions/checkout@v3
101101
- uses : gradle/wrapper-validation-action@v1
@@ -136,6 +136,56 @@ jobs :
136136
with :
137137
report_paths : '**/build/test-results/test/TEST-*.xml'
138138

139+
performance-tests :
140+
name : Performance tests
141+
runs-on : macos-latest
142+
timeout-minutes : 30
143+
strategy :
144+
# Allow tests to continue on other devices if they fail on one device.
145+
fail-fast : false
146+
matrix :
147+
api-level :
148+
- 29
149+
# Unclear that older versions actually honor command to disable animation.
150+
# Newer versions are reputed to be too slow: https://github.com/ReactiveCircus/android-emulator-runner/issues/222
151+
steps :
152+
- uses : actions/checkout@v3
153+
- name : set up JDK 11
154+
uses : actions/setup-java@v3
155+
with :
156+
distribution : 'zulu'
157+
java-version : 11
158+
159+
## Build before running tests, using cache.
160+
- uses : burrunan/gradle-cache-action@v1
161+
name : Build instrumented tests
162+
with :
163+
gradle-dependencies-cache-key : |
164+
gradle/libs.versions.toml
165+
arguments : |
166+
:benchmarks:performance-poetry:complex-poetry:assembleDebugAndroidTest --no-daemon --stacktrace
167+
concurrent : true
168+
gradle-build-scan-report : false
169+
gradle-distribution-sha-256-sum-warning : false
170+
171+
## Actual task
172+
- name : Instrumentation Tests
173+
uses : reactivecircus/android-emulator-runner@v2
174+
with :
175+
# @ychescale9 suspects Galaxy Nexus is the fastest one
176+
profile : Galaxy Nexus
177+
api-level : ${{ matrix.api-level }}
178+
arch : x86_64
179+
# Skip the benchmarks as this is running on emulators
180+
script : ./gradlew :benchmarks:performance-poetry:complex-poetry:connectedCheck --no-daemon --stacktrace --continue
181+
182+
- name : Upload results
183+
if : ${{ always() }}
184+
uses : actions/upload-artifact@v3
185+
with :
186+
name : instrumentation-test-results-${{ matrix.api-level }}
187+
path : ./**/build/reports/androidTests/connected/**
188+
139189
instrumentation-tests :
140190
name : Instrumentation tests
141191
runs-on : macos-latest
@@ -177,7 +227,7 @@ jobs :
177227
api-level : ${{ matrix.api-level }}
178228
arch : x86_64
179229
# Skip the benchmarks as this is running on emulators
180-
script : ./gradlew connectedCheck -x :benchmarks:dungeon-benchmark:connectedCheck -x :benchmarks:performance-poetry:complex-benchmark:connectedCheck --no-daemon --stacktrace
230+
script : ./gradlew connectedCheck -x :benchmarks:dungeon-benchmark:connectedCheck -x :benchmarks:performance-poetry:complex-benchmark:connectedCheck -x :benchmarks:performance-poetry:complex-poetry:connectedCheck --no-daemon --stacktrace
181231

182232
- name : Upload results
183233
if : ${{ always() }}

benchmarks/performance-poetry/complex-benchmark/src/main/java/com/squareup/benchmarks/performance/complex/poetry/benchmark/ComplexPoetryBenchmarks.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import org.junit.runner.RunWith
3131
* The above can be run as tests using Full, Partial, or No aot compiling on the app.
3232
*
3333
* For the rest of the benchmarks, see individual kdoc.
34+
*
35+
* Note that full benchmark suite without startup tests take 3hr+.
3436
*/
3537
@OptIn(ExperimentalMetricApi::class)
3638
@RunWith(AndroidJUnit4::class)
@@ -203,6 +205,7 @@ class ComplexPoetryBenchmarks {
203205
}
204206
putExtra(PerformancePoetryActivity.EXTRA_PERF_CONFIG_INITIALIZING, true)
205207
putExtra(PerformancePoetryActivity.EXTRA_PERF_CONFIG_ACTION_TRACING, true)
208+
putExtra(PerformancePoetryActivity.EXTRA_TRACE_SELECT_TIMEOUTS, true)
206209
}
207210
}
208211

@@ -278,17 +281,19 @@ class ComplexPoetryBenchmarks {
278281
const val PACKAGE_NAME = "com.squareup.benchmarks.performance.complex.poetry"
279282

280283
val ACTION_TRACE_SECTIONS = listOf(
281-
"E-PoemList-PoemSelected-00",
282-
"Worker-ComplexCallBrowser(2)-Finished-00",
283-
"E-StanzaList-StanzaSelected-00",
284-
"E-StanzaList-Exit-00",
285-
"Worker-ComplexCallBrowser(-1)-Finished-00",
284+
"E-PoemList-PoemSelected-${0.pad()}",
285+
"Worker-ComplexCallBrowser(2)-Finished-${0.pad()}",
286+
"E-StanzaList-StanzaSelected-${0.pad()}",
287+
"E-StanzaList-Exit-${0.pad()}",
288+
"Worker-ComplexCallBrowser(-1)-Finished-${0.pad()}",
286289
) + (0..11).map {
287290
"Worker-PoemLoading-Finished-${it.pad()}"
288291
} + (0..4).map {
289292
"E-StanzaWorkflow-ShowNextStanza-${it.pad()}"
290293
} + (0..4).map {
291294
"E-StanzaWorkflow-ShowPreviousStanza-${it.pad()}"
295+
} + (1..42).map {
296+
"E-Runtime-OnTimeout-${it.pad()}"
292297
}
293298

294299
val ACTION_TRACE_SECTIONS_HIGH_FREQUENCY = ACTION_TRACE_SECTIONS + (0..250).map {

0 commit comments

Comments
 (0)