Skip to content

Commit e53fd4b

Browse files
authored
Add benchmark sub-project (#48)
Resolves #31
1 parent 9feb4f4 commit e53fd4b

File tree

21 files changed

+2939
-3
lines changed

21 files changed

+2939
-3
lines changed

.github/workflows/benchmark.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "Running benchmark"
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 2 * * 1"
7+
8+
jobs:
9+
check-linux:
10+
uses: ./.github/workflows/platform-benchmark.yml
11+
with:
12+
run-on: ubuntu-latest
13+
check-macos:
14+
uses: ./.github/workflows/platform-benchmark.yml
15+
with:
16+
run-on: macos-latest
17+
additional-task: "-x :benchmark:jvmBenchmark"
18+
check-windows:
19+
uses: ./.github/workflows/platform-benchmark.yml
20+
with:
21+
run-on: windows-latest
22+
additional-task: "-x :benchmark:jvmBenchmark"

.github/workflows/check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
ktlintCheck
5454
apiCheck
5555
koverXmlReport
56+
-x :benchmark:benchmark
5657
- name: Upload coverage reports to Codecov
5758
if: inputs.upload-code-coverage
5859
uses: codecov/codecov-action@v3
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Reusable workflow to run a benchmark on the platform
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
run-on:
7+
type: string
8+
required: true
9+
description: "runner to check the project"
10+
additional-task:
11+
type: string
12+
description: additional task to add to gradle call
13+
required: false
14+
default: ""
15+
16+
jobs:
17+
benchmark:
18+
runs-on: ${{ inputs.run-on }}
19+
steps:
20+
- name: 'Checkout Repository'
21+
uses: actions/checkout@v4
22+
with:
23+
submodules: true
24+
- uses: actions/setup-java@v4
25+
with:
26+
distribution: temurin
27+
java-version-file: .ci-java-version
28+
- name: Validate Gradle Wrapper
29+
uses: gradle/[email protected]
30+
- name: Cache konan
31+
uses: actions/[email protected]
32+
with:
33+
path: ~/.konan
34+
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
35+
restore-keys: |
36+
${{ runner.os }}-gradle-
37+
- name: Build with Gradle
38+
uses: gradle/[email protected]
39+
with:
40+
gradle-version: wrapper
41+
arguments: |
42+
--no-daemon
43+
--info
44+
:benchmark:benchmark
45+
${{ inputs.additional-task }}

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ jobs:
6666
publish
6767
closeAndReleaseStagingRepository
6868
-Pversion=${{ needs.version.outputs.RELEASE_VERSION }}
69+
-x :benchmark:benchmark
6970
create_release:
7071
runs-on: ubuntu-latest
7172
needs:

.github/workflows/snapshot_release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
build
4646
publish
4747
koverXmlReport
48+
-x :benchmark:benchmark
4849
- name: Upload coverage reports to Codecov
4950
uses: codecov/codecov-action@v3
5051
env:

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,16 @@ The test are located [here](test-suites).
287287
**NOTE:** _Python 3.* is required to run test-suites._
288288
_It is used to generate list of remote schemas using [this script](test-suites/schema-test-suite/bin/jsonschema_suite)_
289289

290+
## Benchmarking
291+
292+
There is a benchmark project that compares this library with some other ones:
293+
294+
+ [OpenAPI schema validator](https://github.com/openapi-processor/openapi-parser/tree/master/json-schema-validator)
295+
+ [Networknt Schema Validator](https://github.com/networknt/json-schema-validator)
296+
297+
The benchmark is scheduled to run every night on Monday.
298+
You can see the results in the latest workflow execution.
299+
290300
## Developer notes
291301

292302
The update to Kotlin 1.9.22 came with an issue for JS incremental compilation.

benchmark/build.gradle.kts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
plugins {
2+
alias(libs.plugins.kotlin.mutliplatform)
3+
alias(libs.plugins.kotlin.benchmark)
4+
alias(libs.plugins.kotlin.allopen)
5+
}
6+
7+
repositories {
8+
mavenCentral()
9+
}
10+
11+
allOpen {
12+
annotation("org.openjdk.jmh.annotations.State")
13+
}
14+
15+
kotlin {
16+
jvm {
17+
jvmToolchain(11)
18+
}
19+
macosX64()
20+
macosArm64()
21+
iosX64()
22+
iosArm64()
23+
iosSimulatorArm64()
24+
25+
linuxX64()
26+
27+
mingwX64()
28+
29+
applyDefaultHierarchyTemplate()
30+
31+
sourceSets {
32+
commonMain {
33+
dependencies {
34+
implementation(project(":"))
35+
implementation(libs.kotlin.benchmark)
36+
implementation(libs.okio.common)
37+
implementation(libs.kotlin.serialization.json.okio)
38+
}
39+
}
40+
41+
jvmMain {
42+
dependencies {
43+
implementation(project.dependencies.platform(libs.openapi.bom))
44+
implementation(libs.bundles.openapi)
45+
implementation(project.dependencies.platform(libs.jackson.bom))
46+
implementation(libs.bundles.jackson)
47+
48+
implementation(libs.networknt.validator)
49+
}
50+
}
51+
}
52+
}
53+
54+
benchmark {
55+
configurations {
56+
getByName("main") {
57+
warmups = 5
58+
iterations = 3
59+
iterationTime = 1
60+
iterationTimeUnit = "s"
61+
param("objectPath", "$projectDir/data/openapi.json")
62+
param("schemaPath", "$projectDir/data/schemas/openapi_schema.json")
63+
}
64+
}
65+
targets {
66+
register("jvm")
67+
register("macosX64")
68+
register("macosArm64")
69+
register("iosX64")
70+
register("iosArm64")
71+
register("iosSimulatorArm64")
72+
register("linuxX64")
73+
register("mingwX64")
74+
}
75+
}

0 commit comments

Comments
 (0)