test: add benchmark

This commit is contained in:
Nao Yonashiro 2022-02-12 17:55:10 +09:00
parent 4bd7d2399f
commit 62b28d102e
2 changed files with 13 additions and 0 deletions

View File

@ -477,3 +477,13 @@ func Benchmark_Decode_LargeStruct_Stream_GoJsonFirstWinMode(b *testing.B) {
} }
} }
} }
func Benchmark_Decode_LargeSlice_EscapedString_GoJson(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
var v []string
if err := gojson.Unmarshal(LargeSliceEscapedString, &v); err != nil {
b.Fatal(err)
}
}
}

View File

@ -2,6 +2,7 @@ package benchmark
import ( import (
"strconv" "strconv"
"strings"
"github.com/francoispqt/gojay" "github.com/francoispqt/gojay"
) )
@ -208,3 +209,5 @@ func NewLargePayloadEasyJson() *LargePayloadEasyJson {
}, },
} }
} }
var LargeSliceEscapedString = []byte("[" + strings.Repeat(",\"simple plain text\\r\\n\"", 10000)[1:] + "]")