Add benchmark for encoding of bool type

This commit is contained in:
Masaaki Goshima 2021-01-31 01:49:35 +09:00
parent a6ea71d2f6
commit 1c0b7e7c7d
1 changed files with 46 additions and 0 deletions

View File

@ -558,6 +558,52 @@ func Benchmark_Encode_Interface_GoJson(b *testing.B) {
}
}
func Benchmark_Encode_Bool_EncodingJson(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
if _, err := json.Marshal(true); err != nil {
b.Fatal(err)
}
}
}
func Benchmark_Encode_Bool_JsonIter(b *testing.B) {
var json = jsoniter.ConfigCompatibleWithStandardLibrary
b.ReportAllocs()
for i := 0; i < b.N; i++ {
if _, err := json.Marshal(true); err != nil {
b.Fatal(err)
}
}
}
func Benchmark_Encode_Bool_Jettison(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
if _, err := jettison.Marshal(true); err != nil {
b.Fatal(err)
}
}
}
func Benchmark_Encode_Bool_SegmentioJson(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
if _, err := segmentiojson.Marshal(true); err != nil {
b.Fatal(err)
}
}
}
func Benchmark_Encode_Bool_GoJson(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
if _, err := gojson.Marshal(true); err != nil {
b.Fatal(err)
}
}
}
func Benchmark_Encode_Int_EncodingJson(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {