Browse Source

Add k/wasm target to benchmarks/ios/jvm-vs-kotlin-native

bench_with_kwasm
oleksandr.karpovich 7 months ago
parent
commit
ce03ed9ddd
  1. 18
      benchmarks/ios/jvm-vs-kotlin-native/build.gradle.kts
  2. 8
      benchmarks/ios/jvm-vs-kotlin-native/gradle.properties
  3. 2
      benchmarks/ios/jvm-vs-kotlin-native/settings.gradle.kts
  4. 2
      benchmarks/ios/jvm-vs-kotlin-native/src/commonMain/kotlin/benchmarks/visualeffects/HappyNY.kt
  5. 7
      benchmarks/ios/jvm-vs-kotlin-native/src/jsMain/kotlin/main.js.kt
  6. 12
      benchmarks/ios/jvm-vs-kotlin-native/src/jsMain/resources/index.html
  7. 6
      benchmarks/ios/jvm-vs-kotlin-native/src/wasmJsMain/kotlin/main.wasm.kt
  8. 12
      benchmarks/ios/jvm-vs-kotlin-native/src/wasmJsMain/resources/index.html
  9. 4
      benchmarks/ios/jvm-vs-kotlin-native/src/wasmJsMain/resources/load.mjs
  10. 18
      benchmarks/ios/jvm-vs-kotlin-native/webpack.config.d/wasm/config.js

18
benchmarks/ios/jvm-vs-kotlin-native/build.gradle.kts

@ -12,6 +12,7 @@ repositories {
google()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental")
}
kotlin {
@ -36,6 +37,19 @@ kotlin {
}
}
}
js(IR) {
browser()
binaries.executable()
}
wasmJs {
browser {
commonWebpackConfig {
configDirectory = projectDir.resolve("webpack.config.d/wasm")
}
}
binaries.executable()
}
sourceSets {
val commonMain by getting {
@ -81,3 +95,7 @@ tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
compose.experimental {
web.application {}
}

8
benchmarks/ios/jvm-vs-kotlin-native/gradle.properties

@ -1,16 +1,12 @@
compose.version=1.4.1
kotlin.version=1.8.20
compose.version=1.5.10-dev-wasm01
kotlin.version=1.9.20-RC
agp.version=7.0.4
org.gradle.jvmargs=-Xmx3g
kotlin.code.style=official
kotlin.native.useEmbeddableCompilerJar=true
kotlin.native.enableDependencyPropagation=false
kotlin.mpp.enableGranularSourceSetsMetadata=true
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
compose.desktop.verbose=true
android.useAndroidX=true
kotlin.js.webpack.major.version=4
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true

2
benchmarks/ios/jvm-vs-kotlin-native/settings.gradle.kts

@ -5,6 +5,8 @@ pluginManagement {
gradlePluginPortal()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
google()
maven("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental")
}
plugins {

2
benchmarks/ios/jvm-vs-kotlin-native/src/commonMain/kotlin/benchmarks/visualeffects/HappyNY.kt

@ -15,6 +15,7 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import height
import width
import kotlin.js.JsName
import kotlin.math.*
import kotlin.random.Random
@ -38,6 +39,7 @@ data class Star(val x: Dp, val y: Dp, val color: Color, val size: Dp)
val random = Random(123)
@JsName("funRandom")
fun random(): Float = random.nextFloat()
class DoubleRocket(val particle: Particle) {

7
benchmarks/ios/jvm-vs-kotlin-native/src/jsMain/kotlin/main.js.kt

@ -0,0 +1,7 @@
import org.jetbrains.skiko.wasm.onWasmReady
fun main() {
onWasmReady {
runBenchmarks()
}
}

12
benchmarks/ios/jvm-vs-kotlin-native/src/jsMain/resources/index.html

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Benchmark</title>
<script src="skiko.js"></script>
</head>
<body>
It takes ~ 1 minute here and blocks the UI. See the console for results (open it before starting the page).
<script src="compose-benchmarks.js"></script>
</body>
</html>

6
benchmarks/ios/jvm-vs-kotlin-native/src/wasmJsMain/kotlin/main.wasm.kt

@ -0,0 +1,6 @@
fun main() {
println("Started...")
runBenchmarks()
println("Completed!")
}

12
benchmarks/ios/jvm-vs-kotlin-native/src/wasmJsMain/resources/index.html

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Benchmark K/Wasm</title>
<script src="skiko.js"></script>
<script src="compose-benchmarks.js"></script>
</head>
<body>
See the console output...
</body>
</html>

4
benchmarks/ios/jvm-vs-kotlin-native/src/wasmJsMain/resources/load.mjs

@ -0,0 +1,4 @@
import { instantiate } from './compose-benchmarks-wasm-js.uninstantiated.mjs';
await wasmSetup;
await instantiate({ skia: Module['asm'] });

18
benchmarks/ios/jvm-vs-kotlin-native/webpack.config.d/wasm/config.js

@ -0,0 +1,18 @@
config.entry = {
main: [require('path').resolve(__dirname, "kotlin/load.mjs")]
};
class IgnoreImportErrorsPlugin {
apply(compiler) {
compiler.hooks.done.tap('IgnoreImportErrorsPlugin', (stats) => {
stats.compilation.errors = stats.compilation.errors.filter((error) => {
if (error.message.includes("skia")) {
return false; // Remove the error
}
return true; // Keep the error
});
});
}
}
config.plugins.push(new IgnoreImportErrorsPlugin());
Loading…
Cancel
Save