1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-27 08:30:57 +02:00
json-iterator/benchmarks/encode_string_test.go

26 lines
463 B
Go
Raw Normal View History

2018-02-05 15:43:37 +02:00
package test
import (
"bytes"
2018-02-05 16:45:04 +02:00
"github.com/json-iterator/go"
"testing"
2018-02-05 15:43:37 +02:00
)
func Benchmark_encode_string_with_SetEscapeHTML(b *testing.B) {
type V struct {
S string
B bool
I int
}
var json = jsoniter.ConfigCompatibleWithStandardLibrary
b.ReportAllocs()
for i := 0; i < b.N; i++ {
buf := &bytes.Buffer{}
enc := json.NewEncoder(buf)
enc.SetEscapeHTML(true)
if err := enc.Encode(V{S: "s", B: true, I: 233}); err != nil {
b.Fatal(err)
}
}
}