Giter Club home page Giter Club logo

go-benchmark's Introduction

The goal is to prove jsoniter is not slow, not to prove it is the fastest, at least good enough. My motivation of inventing json iterator is the flexibility to mix high level and low level api. Performance is the by-product of schema based parsing.

  • CPU: i7-6700K @ 4.0G
  • Level 1 cache size: 4 x 32 KB 8-way set associative instruction caches
  • Level 2 cache size: 4 x 256 KB 4-way set associative caches
  • Level 3 cache size: 8 MB 16-way set associative shared cache
  • Go: 1.8beta1

small payload

https://github.com/json-iterator/go-benchmark/blob/master/src/github.com/json-iterator/go-benchmark/benchmark_small_payload_test.go

jsonparser jsoniter pull-api jsoniter reflect-api encoding/json easyjson
599 ns/op 515 ns/op 684 ns/op 2453 ns/op 687 ns/op
64 B/op 64 B/op 256 B/op 864 B/op 64 B/op
2 allocs/op 2 allocs/op 4 allocs/op 31 allocs/op 2 allocs/op

pull-api is fast, and reflection-api is not slow either. encoding/json is not that slow on i7-6700K, but much slower on cpu with smaller cache.

small

medium payload

https://github.com/json-iterator/go-benchmark/blob/master/src/github.com/json-iterator/go-benchmark/benchmark_medium_payload_test.go

jsonparser jsoniter pull-api jsoniter reflect-api encoding/json easyjson
5238 ns/op 4111 ns/op 4708 ns/op 24939 ns/op 7361 ns/op
104 B/op 104 B/op 368 B/op 808 B/op 248 B/op
4 allocs/op 4 allocs/op 14 allocs/op 18 allocs/op 8 allocs/op

reflect-api even out-performed the hand written parser

medium

large payload

https://github.com/json-iterator/go-benchmark/blob/master/src/github.com/json-iterator/go-benchmark/benchmark_large_payload_test.go

jsonparser jsoniter pull-api encoding/json
38334 ns/op 38463 ns/op 290778 ns/op
0 B/op 0 B/op 2128 B/op
0 allocs/op 0 allocs/op 46 allocs/op

This is a pure counting usage. jsonparser is faster

large

large file

test file used: https://github.com/json-iterator/test-data/blob/master/large-file.json

jsonparser jsoniter pull-api encoding/json
42698634 ns/op 37760014 ns/op 235354502 ns/op
67107104 B/op 4248 B/op 71467896 B/op
19 allocs/op 5 allocs/op 272477 allocs/op

The difference here is because jsonparser take []byte as input, but jsoniter can take io.Reader as input.

large-file

go-benchmark's People

Contributors

taowen avatar

Watchers

James Cloos 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.