...

Source file src/github.com/json-iterator/go/benchmarks/encode_string_test.go

Documentation: github.com/json-iterator/go/benchmarks

     1  package test
     2  
     3  import (
     4  	"bytes"
     5  	"github.com/json-iterator/go"
     6  	"testing"
     7  )
     8  
     9  func Benchmark_encode_string_with_SetEscapeHTML(b *testing.B) {
    10  	type V struct {
    11  		S string
    12  		B bool
    13  		I int
    14  	}
    15  	var json = jsoniter.ConfigCompatibleWithStandardLibrary
    16  	b.ReportAllocs()
    17  	for i := 0; i < b.N; i++ {
    18  		buf := &bytes.Buffer{}
    19  		enc := json.NewEncoder(buf)
    20  		enc.SetEscapeHTML(true)
    21  		if err := enc.Encode(V{S: "s", B: true, I: 233}); err != nil {
    22  			b.Fatal(err)
    23  		}
    24  	}
    25  }
    26  

View as plain text