Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Benchmarks of Go serialization methods

NotificationsYou must be signed in to change notification settings

alecthomas/go_serialization_benchmarks

Repository files navigation

Gitter chat

This is a test suite for benchmarking various Go serialization methods.

Current Serialization Results

https://alecthomas.github.io/go_serialization_benchmarks

Running the 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. --validate

To update the benchmark report:

go run. --genreport

To update the benchmark report with a longer benchmark run (to get more accurate results):

gotest -tags genreport -run TestGenerateReport -benchtime 10s -timeout 1h#--validate

Recommendation

If correctness and interoperability are the mostimportant factorsJSON orProtobuf are your best options.

But as always, make your own choice based on your requirements.

Adding New Serializers

Review the following instructionsbefore opening the PR to add a newserializer:

  • Create all the required serializer code ininternal/<short serializer name>.
  • Add an entry to the serializer inbenchmarks.go.
  • If the serializer supports both reusing/not reusing its marshalling buffer:
    • Add both aserializer andserializer/reuse entries, each onerespectively reusing/not reusing the resulting marshalling buffer. Set theBufferReuseMarshal flag accordingly.
  • If the serializer supports both safe and unsafe string unmarshalling:
    • Add both aserializer andserializer/unsafe entries, each onerespectively unmarshalling into safe and unsafe strings. Set theUnsafeStringUnmarshal flag accordingly.
  • If the serializer supports both marshalling buffer reuse and unsafe stringunmarshalling, merge both options into a singleserializer/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

Data

The data being serialized is the following structure with randomly generated values:

typeAstruct {NamestringBirthDay time.TimePhonestringSiblingsintSpouseboolMoneyfloat64}

About

Benchmarks of Go serialization methods

Topics

Resources

Stars

Watchers

Forks

Contributors45


[8]ページ先頭

©2009-2025 Movatter.jp