test: add benchmark

This commit is contained in:
Nao Yonashiro 2022-03-13 08:20:12 +09:00
parent e99e62dcbc
commit 1ee186da17
1 changed files with 19 additions and 0 deletions

View File

@ -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)
}
})
}