MCPcopy Index your code
hub / github.com/segmentio/encoding / BenchmarkCodeDecoder

Function BenchmarkCodeDecoder

json/golang_bench_test.go:149–172  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

147}
148
149func BenchmarkCodeDecoder(b *testing.B) {
150 b.ReportAllocs()
151 if codeJSON == nil {
152 b.StopTimer()
153 codeInit()
154 b.StartTimer()
155 }
156 b.RunParallel(func(pb *testing.PB) {
157 var buf bytes.Buffer
158 dec := NewDecoder(&buf)
159 var r codeResponse
160 for pb.Next() {
161 buf.Write(codeJSON)
162 // hide EOF
163 buf.WriteByte('\n')
164 buf.WriteByte('\n')
165 buf.WriteByte('\n')
166 if err := dec.Decode(&r); err != nil {
167 b.Fatal("Decode:", err)
168 }
169 }
170 })
171 b.SetBytes(int64(len(codeJSON)))
172}
173
174func BenchmarkUnicodeDecoder(b *testing.B) {
175 b.ReportAllocs()

Callers

nothing calls this directly

Calls 5

DecodeMethod · 0.95
codeInitFunction · 0.85
WriteMethod · 0.80
NewDecoderFunction · 0.70
NextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…