- Notifications
You must be signed in to change notification settings - Fork163
Benchmarks of Go serialization methods
alecthomas/go_serialization_benchmarks
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
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 withgithub.com/alecthomas/go_serialization_benchmarks@latest.
go run.To validate the correctness of the serializers:
go run. --validateTo update the benchmark report:
go run. --genreportTo update the benchmark report with a longer benchmark run (to get more accurate results):
gotest -tags genreport -run TestGenerateReport -benchtime 10s -timeout 1h#--validate
If correctness and interoperability are the mostimportant factorsJSON orProtobuf are your best options.
But as always, make your own choice based on your requirements.
Review the following instructionsbefore opening the PR to add a newserializer:
- Create all the required serializer code in
internal/<short serializer name>. - Add an entry to the serializer inbenchmarks.go.
- If the serializer supports both reusing/not reusing its marshalling buffer:
- Add both a
serializerandserializer/reuseentries, each onerespectively reusing/not reusing the resulting marshalling buffer. Set theBufferReuseMarshalflag accordingly.
- Add both a
- If the serializer supports both safe and unsafe string unmarshalling:
- Add both a
serializerandserializer/unsafeentries, each onerespectively unmarshalling into safe and unsafe strings. Set theUnsafeStringUnmarshalflag accordingly.
- Add both a
- If the serializer supports both marshalling buffer reuse and unsafe stringunmarshalling, merge both options into a single
serializer/unsafe_reuseentry (check the baseline serializer for an example). - Regenerate the report by running:
go run . --genreport- Include the updated report data in your PR
The data being serialized is the following structure with randomly generated values:
typeAstruct {NamestringBirthDay time.TimePhonestringSiblingsintSpouseboolMoneyfloat64}
About
Benchmarks of Go serialization methods
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
