Skip to content

Commit

Permalink
Add wasmJs target
Browse files Browse the repository at this point in the history
  • Loading branch information
eygraber committed May 7, 2024
1 parent 9c8e465 commit 3812825
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
- name: Run Node JS benchmark
run: ./gradlew :jsonpath-benchmarks:jsNodeProductionRun

- name: Run Node WasmJs benchmark
run: ./gradlew :jsonpath-benchmarks:wasmJsNodeProductionRun

- name: Run Native Linux benchmark
run: ./gradlew :jsonpath-benchmarks:runReleaseExecutableLinuxX64

Expand Down
2 changes: 1 addition & 1 deletion Dangerfile.df.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ danger(args) {
# Don't merge if there is a WIP or Hold label applied
# --------------------------------------------------------------------------------------------------------------------
*/
if("Hold" in labelNames) fail("This PR cannot be merged with a hold label applied")
if("hold" in labelNames) fail("This PR cannot be merged with a hold label applied")

/*
# --------------------------------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ gradleConventionsKmpDefaults {
KmpTarget.Macos,
KmpTarget.Mingw,
KmpTarget.Tvos,
KmpTarget.WasmJs,
KmpTarget.Watchos,
)
}
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ dokka = "1.9.20"

jackson = "2.17.1"

kotlin = "1.9.23"
kotlin = "1.9.24"

kotest = "5.8.1"
kotest = "5.9.0.1441-SNAPSHOT"

ktlint = "1.2.1"

Expand Down
1 change: 1 addition & 0 deletions jsonpath-benchmarks/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ kotlin {
KmpTarget.Linux,
KmpTarget.Macos,
KmpTarget.Mingw,
KmpTarget.WasmJs,
project = project,
binaryType = BinaryType.Executable,
ignoreDefaultTargets = true,
Expand Down
29 changes: 29 additions & 0 deletions jsonpath-benchmarks/src/wasmJsMain/kotlin/WasmJsBenchmark.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import com.nfeld.jsonpathkt.Benchmark
import com.nfeld.jsonpathkt.BenchmarkOp
import com.nfeld.jsonpathkt.JsonPath
import com.nfeld.jsonpathkt.LARGE_JSON
import com.nfeld.jsonpathkt.kotlinx.resolvePathOrNull
import kotlinx.serialization.json.Json

fun main() {
WasmJsBenchmark()
}

object WasmJsBenchmark : Benchmark() {
// pre-parse json
private val kotlinxJson = Json.parseToJsonElement(LARGE_JSON)

override val targetName = "WasmJs"

operator fun invoke() {
runAllBenchmarks()
}

override fun pathResolveBenchmarks(): List<BenchmarkOp> = listOf(
BenchmarkOp(name = "JsonPathKt", f = kotlinxJson::resolvePathOrNull),
)

override fun pathCompilationBenchmarks(): List<BenchmarkOp> = listOf(
BenchmarkOp(name = "JsonPathKt", f = JsonPath.Companion::compile),
)
}
3 changes: 3 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.eygraber.conventions.Env
import com.eygraber.conventions.repositories.mavenCentralSnapshotsS01

pluginManagement {
repositories {
Expand All @@ -14,6 +15,8 @@ dependencyResolutionManagement {
@Suppress("UnstableApiUsage")
repositories {
mavenCentral()
// TODO: remove when Kotest releases 5.9.0
mavenCentralSnapshotsS01()
}
}