I’m working on a new decoding library for ReScript, and decided to make a benchmark for other popular libraries to get the idea of the current state of the ecosystem.
The result highlight is:
- decco ~ 2_715_999 op/s
- bs-json ~ 1_575_450 op/s
- rescript-struct ~ 1_555_331 op/s
- rescript-jzon ~ 1_069_012 op/s
For comparison there are some popular JS libraries:
- ajv ~ 31_198_292 op/s (Assertion not decoding)
- zod ~ 405_092 op/s
- runtypes ~ 111_345 op/s
- superstruct ~ 114_114 op/s
You can take a look at the full graph at:
https://dzakh.github.io/rescript-runtime-type-benchmarks/
I haven’t done a benchmark for Js.Json.t
, but if you’re interested in my opinion it should be slower than rescript-jzon
if you want to have a result based API, and slower than bs-json
if you want to have exception based API.
Also, I’ve taken a look at the code generated by decco
, and had a thought that making it a little bit more dirty and unsafe, it might have a similar performance to ajv
or even better. That’s the opposite to my library rescript-struct
where I almost hit a performance maximum caused by library design.
If I missed some good decoding libraries, let me know, I’ll add them to the benchmark.