Golang json encoders\decoders benchmark

Json encoder and decoder benchmark

Test Encode for:

  1. Build-in encoder
  2. https://github.com/mailru/easyjson
  3. https://github.com/json-iterator/go

Test Decode with access to one field for:

  1. Build-in decoder
  2. https://github.com/mailru/easyjson
  3. https://github.com/json-iterator/go
  4. https://github.com/valyala/fastjson (only one field extracted)
  5. https://github.com/tidwall/gjson (only one field extracted)
  6. Parallel https://github.com/valyala/fastjson (only one field extracted)
  7. Parallel https://github.com/tidwall/gjson (only one field extracted)

Test Delete unnecessary field from json document without parsing it into structure:

  1. https://github.com/valyala/fastjson
  2. https://github.com/tidwall/sjson
  3. https://github.com/tidwall/sjson by setting necessary fields in new document (bad idea)
  4. https://github.com/tidwall/gjson by parse to map[interface{}]interface{}, delete fields and Marshal with jsoniter
goos: linux
goarch: amd64
pkg: github.com/satmaelstorm/jsonBenchmark
cpu: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
BenchmarkStdJsonEncode-12                 455626              2907 ns/op            1112 B/op          6 allocs/op
BenchmarkEasyJsonEncode-12               1000000              1325 ns/op             968 B/op          6 allocs/op
BenchmarkJsoniterJsonEncode-12           1000000              1960 ns/op            1112 B/op          6 allocs/op
BenchmarkStdJsonDecode-12                 228279              5276 ns/op             336 B/op         13 allocs/op
BenchmarkEasyJsonDecode-12                663830              1794 ns/op              42 B/op          8 allocs/op
BenchmarkJsoniterDecode-12                366958              3283 ns/op             664 B/op         29 allocs/op
BenchmarkFastJsonDecode-12               1634101               730.6 ns/op             0 B/op          0 allocs/op
BenchmarkGJsonDecode-12                  3851779               318.0 ns/op             3 B/op          1 allocs/op
BenchmarkFastJsonDecodeParallel-12       7178468               170.7 ns/op             0 B/op          0 allocs/op
BenchmarkGJsonDecodeParallel-12         17168725                69.63 ns/op            3 B/op          1 allocs/op
BenchmarkFastJsonDelete-12                426006              5862 ns/op            3916 B/op          9 allocs/op
BenchmarkSJsonDelete-12                    52360             43182 ns/op           38096 B/op         20 allocs/op
BenchmarkSJsonDeleteBySet-12               12549             97480 ns/op           37584 B/op         40 allocs/op
BenchmarkGJsonDeleteByMap-12               47029             35157 ns/op           19958 B/op         46 allocs/op

IMHO:

  1. If you need to encode or decode into a structure, and you want to avoid code generation, take jsoniter, otherwise, an easyjson one is a great way
  2. If you need a small number of fields from a clear location, you can take gjson
  3. If you need to remove fields from the json without decoding it - fastjson will do the best
Owner
Vladislav S
https://haddan.ru, https://rabota.ru
Vladislav S
Similar Resources

Golang json encoders\decoders benchmark

Json encoder and decoder benchmark Test Encode for: Build-in encoder https://github.com/mailru/easyjson https://github.com/json-iterator/go Test Decod

Dec 3, 2021

Benchmark of Golang JSON Libraries

Introduction This is a benchmark for the json packages. You are welcome to open an issue if you find anything wrong or out of date. TL;DR In conclusio

Nov 3, 2022

Cache benchmark for Golang

Cache benchmark for Golang

Cache comparison benchmark for Go This benchmark compares cache algorithms using scrambled zipfian distribution (a few occur very often while many oth

Dec 26, 2022

Continuous Benchmark for cache libraries written in golang.

Simple performance comparison of cache libraries written in golang. Reports Continuous Bencmark Result (click here) Default parameters 256 shards * 32

Oct 26, 2022

Go benchmark harness.

autobench autobench is a framework to compare the performance of Go 1.2 and Go 1.3. usage autobench downloads and builds the latest Go 1.1 and Go tip

Oct 19, 2022

Go HTTP request router and web framework benchmark

Go HTTP Router Benchmark This benchmark suite aims to compare the performance of HTTP request routers for Go by implementing the routing structure of

Dec 27, 2022

:zap: Go web framework benchmark

:zap: Go web framework benchmark

go-web-framework-benchmark This benchmark suite aims to compare the performance of Go web frameworks. It is inspired by Go HTTP Router Benchmark but t

Dec 28, 2022

Key/Value database benchmark

USAGE: kvbench OPTIONS OVERVIEW kvbench is a simple benchmarking tool to evaluate the read performance of a key/value store while writes are being app

Sep 27, 2022

A rapid http(s) benchmark tool written in Go

A rapid http(s) benchmark tool written in Go

gonetx/httpit httpit is a rapid http(s) benchmark tool which on top of fasthttp. Also thanks to cobra and bubbletea. Installation Get binaries from re

Dec 23, 2022

:zap: Go web framework benchmark

:zap: Go web framework benchmark

go-web-framework-benchmark This benchmark suite aims to compare the performance of Go web frameworks. It is inspired by Go HTTP Router Benchmark but t

Dec 31, 2022

A CLI to turn Go's benchmark output into pictures

benchdraw benchdraw allows you to make easy to read picture plots from data in Go's benchmark format, implemented in pure Go. Benchdraw does not try t

Nov 28, 2022

Continuous Benchmark for Go Project

Continuous Benchmark for Go Project

Abstract cob compares benchmarks between the latest commit (HEAD) and the previous commit (HEAD{@1}). The program will fail if the change in score is

Dec 13, 2022

Redis Sorted Sets Benchmark

redis-zbench-go Redis Sorted Sets Benchmark Overview This repo contains code to trigger load ( ZADD ) or query (ZRANGEBYLEX key min max) benchmarks, w

May 18, 2021

Open Source runtime scanner for Linux containers (LXD), It performs security audit checks based on CIS Linux containers Benchmark specification

Open Source runtime scanner for Linux containers (LXD), It performs security audit checks based on CIS Linux containers  Benchmark specification

lxd-probe Scan your Linux container runtime !! Lxd-Probe is an open source audit scanner who perform audit check on a linux container manager and outp

Dec 26, 2022

Test and benchmark KPHP code

Test and benchmark KPHP code

Overview ktest is a tool that makes kphp programs easier to test. ktest phpunit can run PHPUnit tests using KPHP ktest bench run benchmarks using KPHP

Dec 14, 2022

Open Source runtime scanner for OpenShift cluster and perform security audit checks based on CIS RedHat OpenShift Benchmark specification

Open Source runtime scanner for OpenShift cluster and perform security audit checks based on CIS RedHat OpenShift Benchmark specification

OpenShift-Ordeal Scan your Openshift cluster !! OpenShift-Ordeal is an open source audit scanner who perform audit check on OpenShift Cluster and outp

Sep 6, 2022

This benchmark provides a overview of the different SQLite driver performances available in Go.

SQLite/HTTP Server Performance Benchmark This benchmark provides a overview of the different SQLite driver performances available in Go. For benchmark

Aug 8, 2022

A benchmark suite aims to compare the performance of HTTP request routers for Go

Go HTTP Router Benchmark This benchmark suite aims to compare the performance of HTTP request routers for Go by implementing the routing structure of

Oct 25, 2021

Go http server benchmark

Go http server benchmark

go-http-server-benchmark The more connections, nbio cost the less memory, and performance the better than other frameworks. We can serve for 1000k or

Sep 1, 2022
Go benchmark harness.

autobench autobench is a framework to compare the performance of Go 1.2 and Go 1.3. usage autobench downloads and builds the latest Go 1.1 and Go tip

Oct 19, 2022
Go HTTP request router and web framework benchmark

Go HTTP Router Benchmark This benchmark suite aims to compare the performance of HTTP request routers for Go by implementing the routing structure of

Dec 27, 2022
:zap: Go web framework benchmark
:zap: Go web framework benchmark

go-web-framework-benchmark This benchmark suite aims to compare the performance of Go web frameworks. It is inspired by Go HTTP Router Benchmark but t

Dec 28, 2022
Key/Value database benchmark

USAGE: kvbench OPTIONS OVERVIEW kvbench is a simple benchmarking tool to evaluate the read performance of a key/value store while writes are being app

Sep 27, 2022
A rapid http(s) benchmark tool written in Go
A rapid http(s) benchmark tool written in Go

gonetx/httpit httpit is a rapid http(s) benchmark tool which on top of fasthttp. Also thanks to cobra and bubbletea. Installation Get binaries from re

Dec 23, 2022
Go http server benchmark
Go http server benchmark

go-http-server-benchmark The more connections, nbio cost the less memory, and performance the better than other frameworks. We can serve for 1000k or

Sep 1, 2022
Go Script Lang Benchmark

Go Script Lang Benchmark git clone github.com/akkuman/go_script_lang_benchmark c

Nov 9, 2022
Go-driver-benchmark - Driver benchmark with golang

We use ClickkHouse for time-series databases, and the driver's performance is ve

Sep 5, 2022
Redis-benchmark - Simple get, mget and pipelined get benchmark.

redis-benchmark Simple get, mget and pipelined get benchmark. Usage git clone https://github.com/Ali-A-A/redis-benchmark.git cd ./redis-benchmark dock

Dec 31, 2021
Benchmark - Benchmark of logr implementations

Benchmark of logr implementations Implementations a function (can bridge to non-

Nov 6, 2022