Go JSON Benchmarks
The JSON libraries of Go, compared doing the same work.
Every library is measured on the same machine of GitHub Actions, by turns, in amd64 and arm64. Libraries are compared within categories of behavior, which every run checks: a library which behaves differently from its category is still shown, apart and marked with †, with what differs.
Machine
Condition
Operation
Metric
Fairness
- The results depend on the CPU. The machines of GitHub Actions are not the same from run to run, and a library may choose its code by the extensions of the instruction set of the CPU, such as AVX-512: segmentio/encoding, for example, decodes several times faster on a CPU with AVX-512 than on one without it, which can change the order of the libraries. The CPU of each run and its extensions are shown with the results; compare the libraries within a run, not the runs with each other.
- Same machine, by turns. Every library of a run is measured on the same machine, by turns, in several rounds, and the median of the rounds is shown, so that a change of the machine during the run affects every library alike. The machines of GitHub Actions differ from run to run, so the results of different runs are not compared.
- Categories of behavior. A library with an option which makes it do less work is not compared with one doing more: the libraries are grouped in categories of what they do, which every run checks on probes, small inputs which tell a behavior apart ( below ). A library which fails a probe its category requires is shown apart, marked with †.
- Same results. On every payload, a decoded value is compared with the one encoding/json decodes, and an encoded value with encoding/json's output, byte for byte ( as a JSON value where the keys of a map may be in any order ). A result which differs is marked with ‡.
- Same calls. A value is decoded into a new value for each operation, and the encoders encode a pointer to the value. sonic's fastest configuration decodes from a string, as it is at its fastest: the string is made once, outside of the measurement.
- A real program's heap. "With a live heap of 64 MB" is the condition of a real program, which keeps its own data: the GC runs as often for every library. "Without a live heap" favors a library which keeps more memory alive, as the GC then runs less often.
Probes
Verify the results
The result files are produced by the workflow of the repository and attested with GitHub Artifact Attestations, which record the repository, the commit and the workflow run which produced them. Download a result file and verify it with the GitHub CLI:
The attestations of the repository: https://github.com/goccy/go-json/attestations