Add benchmark for Decode of GoJay

This commit is contained in:
Masaaki Goshima 2020-07-31 18:07:40 +09:00
parent 2240ebcb1a
commit 38ac0e025d
1 changed files with 12 additions and 0 deletions

View File

@ -30,6 +30,18 @@ func Benchmark_Decode_SmallStruct_JsonIter(b *testing.B) {
} }
} }
func Benchmark_Decode_SmallStruct_GoJayDecode(b *testing.B) {
b.ReportAllocs()
reader := bytes.NewReader(SmallFixture)
for n := 0; n < b.N; n++ {
reader.Reset(SmallFixture)
result := SmallPayload{}
if err := gojay.NewDecoder(reader).DecodeObject(&result); err != nil {
b.Fatal(err)
}
}
}
func Benchmark_Decode_SmallStruct_GoJay(b *testing.B) { func Benchmark_Decode_SmallStruct_GoJay(b *testing.B) {
b.ReportAllocs() b.ReportAllocs()
for n := 0; n < b.N; n++ { for n := 0; n < b.N; n++ {