Giter Site home page Giter Site logo

go-encoding-benchmark's Introduction

Simple Encoding Benchmark

A benchmark comparison of the following:

  • standard Go library JSON Marhsal/Unmarshal
  • easyjson custom Marshal/Unmarshal
  • standard Go library gob Encode/Decode

Benchmarks executed on the following setup:
MacBook Pro (Retina, 13-inch, Mid 2014)
2,6 GHz Dual-Core Intel Core i5
8 GB 1600 MHz DDR3

[Optional] Update easyjson custom encoder/decoder for project structs with

cd encoding && easyjson -all encoding.go 

Run benchmarks with the following command

cd encoding && go test -bench=.

Results look like the following

goos: darwin
goarch: amd64
pkg: github.com/fpapadopou/go-encoding-benchmark/encoding
Benchmark_StdJSONEncode-4                 888596              1321 ns/op
Benchmark_EasyJsonEncode-4               2997316               400 ns/op
Benchmark_StdGobEncode-4                  172783              5985 ns/op
Benchmark_StdJSONEncode_MidSize-4           2502            431536 ns/op
Benchmark_EasyJsonEncode_MidSize-4         13312             91171 ns/op
Benchmark_StdGobEncode_MidSize-4            9175            142470 ns/op
Benchmark_StdJSONEncode_LargeSize-4           25          44295806 ns/op
Benchmark_EasyJsonEncode_LargeSize-4         122           9148548 ns/op
Benchmark_StdGobEncode_LargeSize-4            78          14089659 ns/op
Benchmark_StdJSONDecode-4                 581384              1977 ns/op
Benchmark_EasyJsonDecode-4               1703674               680 ns/op
Benchmark_StdGobDecode-4                   38575             29062 ns/op
Benchmark_StdJSONDecode_MidSize-4           1959            609825 ns/op
Benchmark_EasyJsonDecode_MidSize-4          4534            286501 ns/op
Benchmark_StdGobDecode_MidSize-4            7022            201647 ns/op
Benchmark_StdJSONDecode_LargeSize-4           16          67875257 ns/op
Benchmark_EasyJsonDecode_LargeSize-4          37          28440457 ns/op
Benchmark_StdGobDecode_LargeSize-4            73          13713334 ns/op
PASS
ok      github.com/fpapadopou/go-encoding-benchmark/encoding    29.169s

Encoding results visualization
Encoding duration graph

Decoding results visualization
Decoding duration graph

Additional Resources
http://ugorji.net/blog/benchmarking-serialization-in-go
https://www.gobeyond.dev/encoding-json/
https://www.xspdf.com/resolution/50593728.html
https://www.speedscope.app/ (rendering cpuprofile flame graphs)

go-encoding-benchmark's People

Contributors

fpapadopou avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.