Skip to content
Open
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
report-boon: ${{ steps.save-output.outputs.report-boon }}
report-corvus: ${{ steps.save-output.outputs.report-corvus }}
report-go-jsonschema: ${{ steps.save-output.outputs.report-go-jsonschema }}
report-harrel-json-schema: ${{ steps.save-output.outputs.report-harrel-json-schema }}
report-hyperjump: ${{ steps.save-output.outputs.report-hyperjump }}
report-json_schemer: ${{ steps.save-output.outputs.report-json_schemer }}
report-jsoncons: ${{ steps.save-output.outputs.report-jsoncons }}
Expand Down
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,22 @@ dist/results/kmp-json-schema-validator/%: \
schemas/%/instances.jsonl \
| dist/results/kmp-json-schema-validator
@$(call docker_run,kmp-json-schema-validator,/workspace/$(word 2,$^) /workspace/$(word 3,$^))

# harrel-json-schema

implementations/harrel-json-schema/.dockertimestamp: \
implementations/harrel-json-schema/app/src/main/java/io/github/sourcemeta/App.java \
implementations/harrel-json-schema/app/build.gradle.kts \
implementations/harrel-json-schema/gradle/libs.versions.toml \
implementations/harrel-json-schema/gradle/wrapper/gradle-wrapper.properties \
implementations/harrel-json-schema/run.sh \
implementations/harrel-json-schema/Dockerfile
docker build -t jsonschema-benchmark/harrel-json-schema implementations/harrel-json-schema
touch $@

dist/results/harrel-json-schema/%: \
implementations/harrel-json-schema/.dockertimestamp \
schemas/%/schema.json \
schemas/%/instances.jsonl \
| dist/results/harrel-json-schema
@$(call docker_run,harrel-json-schema,/workspace/$(word 2,$^) /workspace/$(word 3,$^))
Empty file.
9 changes: 9 additions & 0 deletions implementations/harrel-json-schema/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

5 changes: 5 additions & 0 deletions implementations/harrel-json-schema/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
16 changes: 16 additions & 0 deletions implementations/harrel-json-schema/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# syntax=docker.io/docker/dockerfile:1.7-labs
FROM gradle:8.11.1-jdk21

COPY --exclude=./app/src . /app

WORKDIR /app

# Just download dependencies first
RUN gradle downloadDependencies

# Now copy in the source and compile
COPY ./app/src /app/app/src
RUN gradle compileJava

ENTRYPOINT ["/app/run.sh"]
CMD []
39 changes: 39 additions & 0 deletions implementations/harrel-json-schema/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
application
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

dependencies {
// This dependency is used by the application.
implementation(libs.jacksonDatabind)
implementation(libs.jsonSchema)
}

// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

application {
// Define the main class for the application.
mainClass = "io.github.sourcemeta.App"
}
//
// See https://stackoverflow.com/a/38528497/123695
fun ConfigurationContainer.resolveAll() = this
.filter { it.isCanBeResolved }
.forEach { it.resolve() }

tasks.register("downloadDependencies") {
doLast {
configurations.resolveAll()
buildscript.configurations.resolveAll()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package io.github.sourcemeta;

import dev.harrel.jsonschema.Validator;
import dev.harrel.jsonschema.ValidatorFactory;
import java.io.IOException;
import java.lang.Math;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

public class App {
static int WARMUP_ITERATIONS = 1000;
static long MAX_WARMUP_TIME = (long) 1e9 * 10;

public static boolean validateAll(Validator validator, URI schemaUri, List<String> docs) {
boolean valid = true;
for (String doc : docs) {
Validator.Result result = validator.validate(schemaUri, doc);
if (!result.isValid()) {
valid = false;
}
}
return valid;
}

public static void main(String[] args) throws IOException {
Validator validator = new ValidatorFactory().createValidator();
String schema = new String(Files.readAllBytes(Paths.get(args[0])));

// Register the schema
Long compileStart = System.nanoTime();
URI schemaUri = validator.registerSchema(schema);
Long compileEnd = System.nanoTime();

List<String> docs = Files.readAllLines(Paths.get(args[1]));

Long coldStart = System.nanoTime();
boolean valid = validateAll(validator, schemaUri, docs);
Long coldEnd = System.nanoTime();

if (!valid) {
System.exit(1);
}

// Warmup
long iterations = (long) Math.ceil(((double) MAX_WARMUP_TIME) / (coldEnd - coldStart));
for (int i = 0; i < WARMUP_ITERATIONS; i++) {
validateAll(validator, schemaUri, docs);
}

Long warmStart = System.nanoTime();
validateAll(validator, schemaUri, docs);
Long warmEnd = System.nanoTime();

System.out.println((coldEnd - coldStart) + "," + (warmEnd - warmStart) + "," + (compileEnd - compileStart));
}
}
7 changes: 7 additions & 0 deletions implementations/harrel-json-schema/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[versions]
jackson = "2.18.1"
jsonSchema = "1.7.1"

[libraries]
jacksonDatabind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" }
jsonSchema = { module = "dev.harrel:json-schema", version.ref = "jsonSchema" }
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading