Skip to content

Commit 5577af9

Browse files
committed
log awaitIdle time
1 parent 8eb71ea commit 5577af9

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

compose/ui/ui/src/webTest/kotlin/androidx/compose/ui/OnCanvasTests.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import kotlin.test.AfterTest
2828
import kotlin.test.BeforeTest
2929
import kotlin.test.assertEquals
3030
import kotlin.test.assertTrue
31+
import kotlin.time.measureTime
3132
import kotlinx.browser.document
3233
import kotlinx.browser.window
3334
import kotlinx.coroutines.CoroutineScope
@@ -174,19 +175,19 @@ internal class WebApplicationScope(
174175
) : CoroutineScope by CoroutineScope(scope.coroutineContext + Job()) {
175176
private val initialRecomposers = Recomposer.runningRecomposers.value
176177

177-
suspend fun awaitIdle() {
178+
suspend fun awaitIdle(): Unit = measureTime {
178179
awaitWithYield()
179180

180181
Snapshot.sendApplyNotifications()
181182

182-
for (recomposerInfo in Recomposer.runningRecomposers.value - initialRecomposers) {
183+
val recomposers = Recomposer.runningRecomposers.value - initialRecomposers
184+
println("Recomposers count: ${recomposers.size}\n")
185+
for (recomposerInfo in recomposers) {
183186
recomposerInfo.state.takeWhile { it > Recomposer.State.Idle }.collect()
184187
}
185188

186189
awaitWithYield()
187-
188-
awaitAnimationFrame()
189-
}
190+
}.let { println("Total awaitIdle time: $it\n") }
190191

191192
/**
192193
* awaitAnimationFrame is needed for text input tests,

compose/ui/ui/src/webTest/kotlin/androidx/compose/ui/platform/a11y/CfWA11YTest.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import kotlin.test.assertNotEquals
4141
import kotlin.test.assertNotNull
4242
import kotlin.test.assertNull
4343
import kotlin.test.assertTrue
44+
import kotlin.time.measureTime
4445
import kotlinx.browser.document
4546
import kotlinx.coroutines.CoroutineScope
4647
import kotlinx.coroutines.Dispatchers
@@ -230,19 +231,20 @@ class CfWA11YTest : OnCanvasTests {
230231
}
231232
}
232233
}
234+
suspend fun realDelay(timeMs: Long) {
235+
withContext(Dispatchers.Default) {
236+
delay(timeMs)
237+
}
238+
}
233239

234240
awaitIdle()
241+
235242
val a11yContainer = getA11YContainer()!!
236243

237244
println("making first assets at ${currentTimeMillis()}\n")
238245
assertEquals("",a11yContainer.innerHTML, "No A11Y tree expected yet. Too early. Time = ${currentTimeMillis()}")
239246
assertEquals(0,a11yContainer.childElementCount, "No A11Y tree expected yet. Too early.")
240247

241-
suspend fun realDelay(timeMs: Long) {
242-
withContext(Dispatchers.Default) {
243-
delay(timeMs)
244-
}
245-
}
246248

247249
repeat(20) {
248250
show1 = !show1

0 commit comments

Comments
 (0)