A benchmarking suite for comparing different Rust JSON Schema implementations.
jsonschema(latest version in this repo)- valico (v4.0.0)
- jsonschema-valid (v0.5.2)
- boon (v0.6.1)
To run the benchmarks:
$ cargo bench| Benchmark | Description | Schema Size | Instance Size |
|---|---|---|---|
| OpenAPI | Zuora API validated against OpenAPI 3.0 schema | 18 KB | 4.5 MB |
| Swagger | Kubernetes API (v1.10.0) with Swagger schema | 25 KB | 3.0 MB |
| GeoJSON | Canadian border in GeoJSON format | 4.8 KB | 2.1 MB |
| CITM | Concert data catalog with inferred schema | 2.3 KB | 501 KB |
| Fast | From fastjsonschema benchmarks (valid/invalid) | 595 B | 55 B / 60 B |
| FHIR | Patient example validated against FHIR schema | 3.3 MB | 2.1 KB |
| Recursive | Nested data with $dynamicRef |
1.4 KB | 449 B |
Sources:
- OpenAPI: Zuora, Schema
- Swagger: Kubernetes, Schema
- GeoJSON: Schema
- CITM: Schema inferred via infers-jsonschema
- Fast: fastjsonschema benchmarks
- FHIR: Schema (R4 v4.0.1), Example
| Benchmark | jsonschema_valid | valico | boon | jsonschema (validate) |
|---|---|---|---|---|
| OpenAPI | - | - | 7.05 ms (x5.83) | 1.21 ms |
| Swagger | - | 110.63 ms (x83.18) | 10.27 ms (x7.72) | 1.33 ms |
| GeoJSON | 16.44 ms (x31.00) | 323.62 ms (x610.26) | 19.08 ms (x35.98) | 530.30 µs |
| CITM Catalog | 2.45 ms (x6.15) | 28.33 ms (x71.15) | 1.06 ms (x2.66) | 398.17 µs |
| Fast (Valid) | 928.88 ns (x13.88) | 3.34 µs (x49.91) | 327.17 ns (x4.89) | 66.92 ns |
| Fast (Invalid) | 209.16 ns (x6.21) | 3.42 µs (x101.51) | 394.97 ns (x11.72) | 33.69 ns |
| FHIR | 590.04 ms (x173032.26) | 1.68 ms (x492.67) | 179.24 µs (x52.56) | 3.41 µs |
| Recursive | - | - | 28.48 ms (x5595.28) | 5.09 µs |
Notes:
-
jsonschema_validandvalicodo not handle valid path instances matching the^\\/regex. -
jsonschema_validfails to resolve local references (e.g.#/definitions/definitions) in OpenAPI/Swagger schemas. -
jsonschema_validandvalicofail to resolve local references in the Recursive schema.
You can find benchmark code in benches/ and in the main jsonschema crate. Rust version is 1.92.
Contributions to improve, expand, or optimize the benchmark suite are welcome. This includes adding new benchmarks, ensuring fair representation of real-world use cases, and optimizing the configuration and usage of benchmarked libraries. Such efforts are highly appreciated as they ensure accurate and meaningful performance comparisons.