Add decoding benchmark of easyjson

This commit is contained in:
Masaaki Goshima 2021-02-11 19:13:56 +09:00
parent 5daa24c97c
commit 4092ca4896
1 changed files with 30 additions and 0 deletions

View File

@ -31,6 +31,16 @@ func Benchmark_Decode_SmallStruct_Unmarshal_JsonIter(b *testing.B) {
}
}
func Benchmark_Decode_SmallStruct_Unmarshal_EasyJson(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
result := NewSmallPayloadEasyJson()
if err := result.UnmarshalJSON(SmallFixture); err != nil {
b.Fatal(err)
}
}
}
func Benchmark_Decode_SmallStruct_Unmarshal_GoJay(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
@ -161,6 +171,16 @@ func Benchmark_Decode_MediumStruct_Unmarshal_JsonIter(b *testing.B) {
}
}
func Benchmark_Decode_MediumStruct_Unmarshal_EasyJson(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
result := NewMediumPayloadEasyJson()
if err := result.UnmarshalJSON(MediumFixture); err != nil {
b.Fatal(err)
}
}
}
func Benchmark_Decode_MediumStruct_Unmarshal_GoJay(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
@ -291,6 +311,16 @@ func Benchmark_Decode_LargeStruct_Unmarshal_JsonIter(b *testing.B) {
}
}
func Benchmark_Decode_LargeStruct_Unmarshal_EasyJson(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
result := NewLargePayloadEasyJson()
if err := result.UnmarshalJSON(LargeFixture); err != nil {
b.Fatal(err)
}
}
}
func Benchmark_Decode_LargeStruct_Unmarshal_GoJay(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {