From 1ee186da171a7589103752ea540c199e9a995209 Mon Sep 17 00:00:00 2001 From: Nao Yonashiro Date: Sun, 13 Mar 2022 08:20:12 +0900 Subject: [PATCH] test: add benchmark --- decode_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/decode_test.go b/decode_test.go index 209c658..0c627c8 100644 --- a/decode_test.go +++ b/decode_test.go @@ -3859,3 +3859,22 @@ func TestIssue337(t *testing.T) { t.Fatal("unexpected result", m) } } + +func Benchmark306(b *testing.B) { + type T0 struct { + Str string + } + in := []byte(`{"Str":"` + strings.Repeat(`abcd\"`, 10000) + `"}`) + b.Run("stdjson", func(b *testing.B) { + var x T0 + for i := 0; i < b.N; i++ { + stdjson.Unmarshal(in, &x) + } + }) + b.Run("go-json", func(b *testing.B) { + var x T0 + for i := 0; i < b.N; i++ { + json.Unmarshal(in, &x) + } + }) +}