This is a test suite for benchmarking various Go serialization methods.
https://alecthomas.github.io/go_serialization_benchmarks
To benchmark and validate, without cloning the repository, replace the .
from the commands below with github.com/alecthomas/go_serialization_benchmarks@latest
.
go run .
To validate the correctness of the serializers:
go run . --validate
To update the benchmark report:
go run . --genreport
To update the benchmark report with a longer benchmark run (to get more accurate results):
go test -tags genreport -run TestGenerateReport -benchtime 10s -timeout 1h #--validate
If correctness and interoperability are the most important factors JSON or Protobuf are your best options.
But as always, make your own choice based on your requirements.
Review the following instructions before opening the PR to add a new serializer:
internal/<short serializer name>
.serializer
and serializer/reuse
entries, each oneBufferReuseMarshal
flag accordingly.serializer
and serializer/unsafe
entries, each oneUnsafeStringUnmarshal
flag accordingly.serializer/unsafe_reuse
go run . --genreport
The data being serialized is the following structure with randomly generated values:
type A struct {
Name string
BirthDay time.Time
Phone string
Siblings int
Spouse bool
Money float64
}