mirror of https://github.com/goccy/go-json.git
test: add benchmark
This commit is contained in:
parent
e99e62dcbc
commit
1ee186da17
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue