mirror of https://github.com/goccy/go-json.git
Add valyala/fastjson to benchmark
This commit is contained in:
parent
df4c91ac28
commit
6cd0ab4ca9
|
@ -9,6 +9,7 @@ import (
|
||||||
gojson "github.com/goccy/go-json"
|
gojson "github.com/goccy/go-json"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
segmentiojson "github.com/segmentio/encoding/json"
|
segmentiojson "github.com/segmentio/encoding/json"
|
||||||
|
fastjson "github.com/valyala/fastjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Benchmark_Decode_SmallStruct_Unmarshal_EncodingJson(b *testing.B) {
|
func Benchmark_Decode_SmallStruct_Unmarshal_EncodingJson(b *testing.B) {
|
||||||
|
@ -21,6 +22,17 @@ func Benchmark_Decode_SmallStruct_Unmarshal_EncodingJson(b *testing.B) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Benchmark_Decode_SmallStruct_Unmarshal_FastJson(b *testing.B) {
|
||||||
|
smallFixture := string(SmallFixture)
|
||||||
|
b.ReportAllocs()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
var p fastjson.Parser
|
||||||
|
if _, err := p.Parse(smallFixture); err != nil {
|
||||||
|
b.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Benchmark_Decode_SmallStruct_Unmarshal_JsonIter(b *testing.B) {
|
func Benchmark_Decode_SmallStruct_Unmarshal_JsonIter(b *testing.B) {
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
|
@ -151,6 +163,17 @@ func Benchmark_Decode_MediumStruct_Unmarshal_EncodingJson(b *testing.B) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Benchmark_Decode_MediumStruct_Unmarshal_FastJson(b *testing.B) {
|
||||||
|
mediumFixture := string(MediumFixture)
|
||||||
|
b.ReportAllocs()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
var p fastjson.Parser
|
||||||
|
if _, err := p.Parse(mediumFixture); err != nil {
|
||||||
|
b.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Benchmark_Decode_MediumStruct_Unmarshal_JsonIter(b *testing.B) {
|
func Benchmark_Decode_MediumStruct_Unmarshal_JsonIter(b *testing.B) {
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
|
@ -281,6 +304,17 @@ func Benchmark_Decode_LargeStruct_Unmarshal_EncodingJson(b *testing.B) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Benchmark_Decode_LargeStruct_Unmarshal_FastJson(b *testing.B) {
|
||||||
|
largeFixture := string(LargeFixture)
|
||||||
|
b.ReportAllocs()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
var p fastjson.Parser
|
||||||
|
if _, err := p.Parse(largeFixture); err != nil {
|
||||||
|
b.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Benchmark_Decode_LargeStruct_Unmarshal_JsonIter(b *testing.B) {
|
func Benchmark_Decode_LargeStruct_Unmarshal_JsonIter(b *testing.B) {
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
|
|
|
@ -8,6 +8,7 @@ require (
|
||||||
github.com/json-iterator/go v1.1.9
|
github.com/json-iterator/go v1.1.9
|
||||||
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe
|
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe
|
||||||
github.com/segmentio/encoding v0.2.4
|
github.com/segmentio/encoding v0.2.4
|
||||||
|
github.com/valyala/fastjson v1.6.3
|
||||||
github.com/wI2L/jettison v0.7.1
|
github.com/wI2L/jettison v0.7.1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,8 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
|
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
|
||||||
|
github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc=
|
||||||
|
github.com/valyala/fastjson v1.6.3/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
|
||||||
github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU=
|
github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU=
|
||||||
github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM=
|
github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM=
|
||||||
github.com/wI2L/jettison v0.7.1 h1:XNq/WvSOAiJhFww9F5JZZcBZtKFL2Y/9WHHEHLDq9TE=
|
github.com/wI2L/jettison v0.7.1 h1:XNq/WvSOAiJhFww9F5JZZcBZtKFL2Y/9WHHEHLDq9TE=
|
||||||
|
|
Loading…
Reference in New Issue