mirror of https://github.com/goccy/go-json.git
Add segmentio/encoding/json to benchmark of decoder
This commit is contained in:
parent
22ef64f4a5
commit
8e21f90189
|
@ -8,6 +8,7 @@ import (
|
|||
gojay "github.com/francoispqt/gojay"
|
||||
gojson "github.com/goccy/go-json"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
segmentiojson "github.com/segmentio/encoding/json"
|
||||
)
|
||||
|
||||
func Benchmark_Decode_SmallStruct_Unmarshal_EncodingJson(b *testing.B) {
|
||||
|
@ -50,6 +51,16 @@ func Benchmark_Decode_SmallStruct_Unmarshal_GoJayUnsafe(b *testing.B) {
|
|||
}
|
||||
}
|
||||
|
||||
func Benchmark_Decode_SmallStruct_Unmarshal_SegmentioJson(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for n := 0; n < b.N; n++ {
|
||||
result := SmallPayload{}
|
||||
if err := segmentiojson.Unmarshal(SmallFixture, &result); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Decode_SmallStruct_Unmarshal_GoJson(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
@ -106,6 +117,18 @@ func Benchmark_Decode_SmallStruct_Stream_GoJay(b *testing.B) {
|
|||
}
|
||||
}
|
||||
|
||||
func Benchmark_Decode_SmallStruct_Stream_SegmentioJson(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
reader := bytes.NewReader(SmallFixture)
|
||||
for i := 0; i < b.N; i++ {
|
||||
result := SmallPayload{}
|
||||
reader.Reset(SmallFixture)
|
||||
if err := segmentiojson.NewDecoder(reader).Decode(&result); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Decode_SmallStruct_Stream_GoJson(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
reader := bytes.NewReader(SmallFixture)
|
||||
|
@ -158,6 +181,16 @@ func Benchmark_Decode_MediumStruct_Unmarshal_GoJayUnsafe(b *testing.B) {
|
|||
}
|
||||
}
|
||||
|
||||
func Benchmark_Decode_MediumStruct_Unmarshal_SegmentioJson(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
result := MediumPayload{}
|
||||
if err := segmentiojson.Unmarshal(MediumFixture, &result); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Decode_MediumStruct_Unmarshal_GoJson(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
@ -214,6 +247,18 @@ func Benchmark_Decode_MediumStruct_Stream_GoJay(b *testing.B) {
|
|||
}
|
||||
}
|
||||
|
||||
func Benchmark_Decode_MediumStruct_Stream_SegmentioJson(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
reader := bytes.NewReader(MediumFixture)
|
||||
for n := 0; n < b.N; n++ {
|
||||
reader.Reset(MediumFixture)
|
||||
result := MediumPayload{}
|
||||
if err := segmentiojson.NewDecoder(reader).Decode(&result); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Decode_MediumStruct_Stream_GoJson(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
reader := bytes.NewReader(MediumFixture)
|
||||
|
@ -266,6 +311,16 @@ func Benchmark_Decode_LargeStruct_Unmarshal_GoJayUnsafe(b *testing.B) {
|
|||
}
|
||||
}
|
||||
|
||||
func Benchmark_Decode_LargeStruct_Unmarshal_SegmentioJson(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
result := LargePayload{}
|
||||
if err := segmentiojson.Unmarshal(LargeFixture, &result); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Decode_LargeStruct_Unmarshal_GoJson(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
@ -322,6 +377,18 @@ func Benchmark_Decode_LargeStruct_Stream_GoJay(b *testing.B) {
|
|||
}
|
||||
}
|
||||
|
||||
func Benchmark_Decode_LargeStruct_Stream_SegmentioJson(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
reader := bytes.NewReader(LargeFixture)
|
||||
for i := 0; i < b.N; i++ {
|
||||
result := LargePayload{}
|
||||
reader.Reset(LargeFixture)
|
||||
if err := segmentiojson.NewDecoder(reader).Decode(&result); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Decode_LargeStruct_Stream_GoJson(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
reader := bytes.NewReader(LargeFixture)
|
||||
|
|
Loading…
Reference in New Issue