Skip to content

Add benchmark sub-project #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Running benchmark"

on:
workflow_dispatch:
schedule:
- cron: "0 2 * * 1"

jobs:
check-linux:
uses: ./.github/workflows/platform-benchmark.yml
with:
run-on: ubuntu-latest
check-macos:
uses: ./.github/workflows/platform-benchmark.yml
with:
run-on: macos-latest
additional-task: "-x :benchmark:jvmBenchmark"
check-windows:
uses: ./.github/workflows/platform-benchmark.yml
with:
run-on: windows-latest
additional-task: "-x :benchmark:jvmBenchmark"
1 change: 1 addition & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
ktlintCheck
apiCheck
koverXmlReport
-x :benchmark:benchmark
- name: Upload coverage reports to Codecov
if: inputs.upload-code-coverage
uses: codecov/codecov-action@v3
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/platform-benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Reusable workflow to run a benchmark on the platform

on:
workflow_call:
inputs:
run-on:
type: string
required: true
description: "runner to check the project"
additional-task:
type: string
description: additional task to add to gradle call
required: false
default: ""

jobs:
benchmark:
runs-on: ${{ inputs.run-on }}
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version-file: .ci-java-version
- name: Validate Gradle Wrapper
uses: gradle/[email protected]
- name: Cache konan
uses: actions/[email protected]
with:
path: ~/.konan
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with Gradle
uses: gradle/[email protected]
with:
gradle-version: wrapper
arguments: |
--no-daemon
--info
:benchmark:benchmark
${{ inputs.additional-task }}
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
publish
closeAndReleaseStagingRepository
-Pversion=${{ needs.version.outputs.RELEASE_VERSION }}
-x :benchmark:benchmark
create_release:
runs-on: ubuntu-latest
needs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/snapshot_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
build
publish
koverXmlReport
-x :benchmark:benchmark
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,16 @@ The test are located [here](test-suites).
**NOTE:** _Python 3.* is required to run test-suites._
_It is used to generate list of remote schemas using [this script](test-suites/schema-test-suite/bin/jsonschema_suite)_

## Benchmarking

There is a benchmark project that compares this library with some other ones:

+ [OpenAPI schema validator](https://github.com/openapi-processor/openapi-parser/tree/master/json-schema-validator)
+ [Networknt Schema Validator](https://github.com/networknt/json-schema-validator)

The benchmark is scheduled to run every night on Monday.
You can see the results in the latest workflow execution.

## Developer notes

The update to Kotlin 1.9.22 came with an issue for JS incremental compilation.
Expand Down
75 changes: 75 additions & 0 deletions benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
plugins {
alias(libs.plugins.kotlin.mutliplatform)
alias(libs.plugins.kotlin.benchmark)
alias(libs.plugins.kotlin.allopen)
}

repositories {
mavenCentral()
}

allOpen {
annotation("org.openjdk.jmh.annotations.State")
}

kotlin {
jvm {
jvmToolchain(11)
}
macosX64()
macosArm64()
iosX64()
iosArm64()
iosSimulatorArm64()

linuxX64()

mingwX64()

applyDefaultHierarchyTemplate()

sourceSets {
commonMain {
dependencies {
implementation(project(":"))
implementation(libs.kotlin.benchmark)
implementation(libs.okio.common)
implementation(libs.kotlin.serialization.json.okio)
}
}

jvmMain {
dependencies {
implementation(project.dependencies.platform(libs.openapi.bom))
implementation(libs.bundles.openapi)
implementation(project.dependencies.platform(libs.jackson.bom))
implementation(libs.bundles.jackson)

implementation(libs.networknt.validator)
}
}
}
}

benchmark {
configurations {
getByName("main") {
warmups = 5
iterations = 3
iterationTime = 1
iterationTimeUnit = "s"
param("objectPath", "$projectDir/data/openapi.json")
param("schemaPath", "$projectDir/data/schemas/openapi_schema.json")
}
}
targets {
register("jvm")
register("macosX64")
register("macosArm64")
register("iosX64")
register("iosArm64")
register("iosSimulatorArm64")
register("linuxX64")
register("mingwX64")
}
}
Loading