@@ -31,43 +31,35 @@ $ pytest benches/bench.py
3131| GeoJSON | Canadian border in GeoJSON format | 4.8 KB | 2.1 MB |
3232| CITM | Concert data catalog with inferred schema | 2.3 KB | 501 KB |
3333| Fast | From fastjsonschema benchmarks (valid/invalid) | 595 B | 55 B / 60 B |
34+ | FHIR | Patient example validated against FHIR schema | 3.3 MB | 2.1 KB |
3435
3536Sources:
3637- OpenAPI: [ Zuora] ( https://github.com/APIs-guru/openapi-directory/blob/1afd351ddf50e050acdb52937a819ef1927f417a/APIs/zuora.com/2021-04-23/openapi.yaml ) , [ Schema] ( https://spec.openapis.org/oas/3.0/schema/2021-09-28 )
3738- Swagger: [ Kubernetes] ( https://raw.githubusercontent.com/APIs-guru/openapi-directory/master/APIs/kubernetes.io/v1.10.0/swagger.yaml ) , [ Schema] ( https://github.com/OAI/OpenAPI-Specification/blob/main/_archive_/schemas/v2.0/schema.json )
3839- GeoJSON: [ Schema] ( https://geojson.org/schema/FeatureCollection.json )
3940- CITM: Schema inferred via [ infers-jsonschema] ( https://github.com/Stranger6667/infers-jsonschema )
4041- Fast: [ fastjsonschema benchmarks] ( https://github.com/horejsek/python-fastjsonschema/blob/master/performance.py#L15 )
42+ - FHIR: [ Schema] ( http://hl7.org/fhir/R4/fhir.schema.json.zip ) (R4 v4.0.1), [ Example] ( http://hl7.org/fhir/R4/patient-example-d.json.html )
4143
4244## Results
4345
4446### Comparison with Other Libraries
4547
46- | Benchmark | fastjsonschema | jsonschema | jsonschema-rs |
48+ | Benchmark | fastjsonschema | jsonschema | jsonschema-rs (validate) |
4749| ---------------| ----------------| ---------------| ----------------|
48- | OpenAPI | - (1) | 640.34 ms (** x94.35** ) | 6.79 ms |
49- | Swagger | - (1) | 1134.76 ms (** x232.81** )| 4.88 ms |
50- | Canada (GeoJSON) | 10.43 ms (** x4.33** ) | 785.21 ms (** x325.59** ) | 2.41 ms |
51- | CITM Catalog | 4.97 ms (** x3.66** ) | 82.42 ms (** x60.67** ) | 1.36 ms |
52- | Fast (Valid) | 1.95 µs (** x6.49** ) | 35.81 µs (** x119.15** ) | 300.55 ns |
53- | Fast (Invalid)| 2.17 µs (** x4.14** ) | 35.83 µs (** x68.31** ) | 524.50 ns |
54-
55- ### jsonschema-rs Performance: ` validate ` vs ` is_valid `
56-
57- | Benchmark | validate | is_valid | Speedup |
58- | ---------------| ------------| ------------| ---------|
59- | OpenAPI | 6.79 ms | 6.84 ms | ** 0.99x** |
60- | Swagger | 4.88 ms | 4.73 ms | ** 1.03x** |
61- | Canada (GeoJSON) | 2.41 ms | 2.34 ms | ** 1.03x** |
62- | CITM Catalog | 1.36 ms | 1.28 ms | ** 1.06x** |
63- | Fast (Valid) | 300.55 ns | 249.95 ns | ** 1.20x** |
64- | Fast (Invalid)| 524.50 ns | 561.00 ns | ** 0.93x** |
50+ | OpenAPI | - (1) | 533.80 ms (** x72.88** ) | 7.3264 ms |
51+ | Swagger | - (1) | 970.32 ms (** x193.34** )| 5.0193 ms |
52+ | Canada (GeoJSON) | 9.521 ms (** x3.88** ) | 738.28 ms (** x300.61** ) | 2.4559 ms |
53+ | CITM Catalog | 4.0752 ms (** x2.85** ) | 76.05 ms (** x53.26** ) | 1.4281 ms |
54+ | Fast (Valid) | 1.933 µs (** x6.90** ) | 32.124 µs (** x114.75** ) | 279.95 ns |
55+ | Fast (Invalid)| 2.073 µs (** x4.24** ) | 32.245 µs (** x65.89** ) | 489.35 ns |
56+ | FHIR | 1.9352 ms (** x452.40** ) | 11.463 ms (** x2679.55** ) | 4.2780 µs |
6557
6658Notes:
6759
68601 . ` fastjsonschema ` fails to compile the Open API spec due to the presence of the ` uri-reference ` format (that is not defined in Draft 4). However, unknown formats are explicitly supported by the spec.
6961
70- You can find benchmark code in [ benches/] ( benches/ ) , Python version ` 3.13 .0 ` , Rust version ` 1.82 ` .
62+ You can find benchmark code in [ benches/] ( benches/ ) , Python version ` 3.14 .0 ` , Rust version ` 1.91.1 ` .
7163
7264## Contributing
7365
0 commit comments