diff --git a/web/benchmark-core/build.gradle.kts b/web/benchmark-core/build.gradle.kts index be42e07216..0f8cc7067a 100644 --- a/web/benchmark-core/build.gradle.kts +++ b/web/benchmark-core/build.gradle.kts @@ -42,9 +42,11 @@ kotlin { } } +val BENCHMARKS_PATH = "reports/tests/jsTest/classes/org.jetbrains.compose.web.tests.benchmarks.BenchmarkTests.html" + val printBenchmarkResults by tasks.registering { doLast { - val report = buildDir.resolve("reports/tests/jsTest/classes/BenchmarkTests.html").readText() + val report = buildDir.resolve(BENCHMARKS_PATH).readText() val stdout = "#.*;".toRegex().findAll(report).map { it.value }.firstOrNull() val benchmarks = stdout?.split(";")?.mapNotNull { diff --git a/web/benchmark-core/src/jsTest/kotlin/BenchmarkComposables.kt b/web/benchmark-core/src/jsTest/kotlin/BenchmarkComposables.kt index 21956d2ea0..4bd216b185 100644 --- a/web/benchmark-core/src/jsTest/kotlin/BenchmarkComposables.kt +++ b/web/benchmark-core/src/jsTest/kotlin/BenchmarkComposables.kt @@ -1,3 +1,5 @@ +package org.jetbrains.compose.web.tests.benchmarks + import androidx.compose.runtime.Composable import org.jetbrains.compose.web.css.* import org.jetbrains.compose.web.css.selectors.* @@ -6,7 +8,7 @@ import org.jetbrains.compose.web.dom.* import org.jetbrains.compose.web.* @Composable -fun AddItems(count: Int) { +internal fun AddItems(count: Int) { repeat(count) { Div { P { @@ -25,7 +27,7 @@ fun AddItems(count: Int) { } @Composable -fun AddItems(list: List) { +internal fun AddItems(list: List) { list.forEach { Div { P { diff --git a/web/benchmark-core/src/jsTest/kotlin/BenchmarkTests.kt b/web/benchmark-core/src/jsTest/kotlin/BenchmarkTests.kt index d3e4af9c54..0bbdc3eb59 100644 --- a/web/benchmark-core/src/jsTest/kotlin/BenchmarkTests.kt +++ b/web/benchmark-core/src/jsTest/kotlin/BenchmarkTests.kt @@ -1,3 +1,5 @@ +package org.jetbrains.compose.web.tests.benchmarks + import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.mutableStateOf import kotlinx.browser.window diff --git a/web/benchmark-core/src/jsTest/kotlin/TestUtils.kt b/web/benchmark-core/src/jsTest/kotlin/TestUtils.kt deleted file mode 100644 index 5ebdbc1a4d..0000000000 --- a/web/benchmark-core/src/jsTest/kotlin/TestUtils.kt +++ /dev/null @@ -1,28 +0,0 @@ -import kotlinx.browser.document -import org.w3c.dom.HTMLElement -import org.w3c.dom.MutationObserver -import org.w3c.dom.MutationObserverInit -import kotlin.coroutines.resume -import kotlin.coroutines.suspendCoroutine - -private object MutationObserverOptions : MutationObserverInit { - override var childList: Boolean? = true - override var attributes: Boolean? = true - override var characterData: Boolean? = true - override var subtree: Boolean? = true - override var attributeOldValue: Boolean? = true -} - -internal suspend fun waitForChanges(elementId: String) { - waitForChanges(document.getElementById(elementId) as HTMLElement) -} - -internal suspend fun waitForChanges(element: HTMLElement) { - suspendCoroutine { continuation -> - val observer = MutationObserver { mutations, observer -> - continuation.resume(Unit) - observer.disconnect() - } - observer.observe(element, MutationObserverOptions) - } -} \ No newline at end of file