command
module
Version:
v0.0.0-...-5c22601
Opens a new window with list of versions in this module.
Published: Oct 6, 2019
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶

go-json-benchmark
Benchmark suite for JSON parsing and serialization.
Libraries
Library |
Notes |
encoding/json (aka 'std') |
Testing Marshal/Unmarshal rather than Decode/Encode since this benchmark suite assumes JSON exists in memory and not incoming from a stream |
easyjson |
Generates parser methods structs defined in <data_file>.go . Testing MarshalJSON/UnmarshalJSON. |
ffjson |
Generates parser methods structs defined in <data_file>.go . Testing MarshalFast/UnmarshalFast |
jsoniter |
Testing Marshal/Unmarshal. |
jingo |
Testing Marshal (no Unmarshal). Requires initializing an encoder per struct/slice that should be marshaled. Currently does not marshal maps. |
Benchmarks
Benchmark |
Description |
Marshal |
Encode JSON data from a Go type or struct |
Unmarshal |
Decode JSON data from memory into to a Go type or struct |
Each benchmark should be tested against each dataset. Generic benchmark helpers are defined in benchmark.go
.
Datasets
JSON file |
Size |
Description |
small.json source |
1KB |
|
large.json source |
1687KB |
A big benchmark file with indentation used in several Java JSON parser benchmarks. |
canada.json source |
2199KB |
Contour of Canada border in GeoJSON format. Contains a lot of real numbers. |
These datasets were pulled from nativejson-benchmark. Data structs are defined in data.go
.
Results
Results of Marshal benchmarking:
Rank |
Library |
Performance |
1 |
jingo |
326 ns/op |
2 |
ffjson |
327 ns/op |
3 |
easyjson |
12379009 ns/op |
4 |
standardjson |
26374413 ns/op |
5 |
jsoniter |
26768552 ns/op |
Results of Unmarshal benchmarking:
Rank |
Library |
Performance |
1 |
easyjson |
20851164 ns/op |
2 |
ffjson |
21516266 ns/op |
3 |
jsoniter |
27719141 ns/op |
4 |
standardjson |
39032163 ns/op |
The average across all datasets is calculated for each performance metric.
Adding new libraries for benchmarking
- create LIBNAME_test.go
- create each benchmark * each dataset - use the base benchmark helpers in benchmark.go if applicable
TODO
- makefile
- CI/CD
- data presentation
- benchmark for libs that support field querying rather than converting to/from predefined struct
Documentation
¶
There is no documentation for this package.
Source Files
¶
Directories
¶
internal
|
|
rank
Tool to generate benchmark ranks and output back to README using templating
|
Tool to generate benchmark ranks and output back to README using templating |
|
|
Click to show internal directories.
Click to hide internal directories.