From 4092ca48964c19e7d85580bf7d35f1ac7b4488b2 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Thu, 11 Feb 2021 19:13:56 +0900 Subject: [PATCH] Add decoding benchmark of easyjson --- benchmarks/decode_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/benchmarks/decode_test.go b/benchmarks/decode_test.go index aeb33db..011fed3 100644 --- a/benchmarks/decode_test.go +++ b/benchmarks/decode_test.go @@ -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++ {