MCPcopy
hub / github.com/TarsCloud/TarsGo / BenchmarkString

Function BenchmarkString

tars/protocol/codec/codec_test.go:304–326  ·  view source on GitHub ↗

BenchmarkString benchmark the read and write the string.

(t *testing.B)

Source from the content-addressed store, hash-verified

302
303// BenchmarkString benchmark the read and write the string.
304func BenchmarkString(t *testing.B) {
305 b := NewBuffer()
306
307 for i := 0; i < 200; i++ {
308 err := b.WriteString("hahahahahahahahahahahahahahahahahahahaha", byte(i))
309 if err != nil {
310 t.Error(err)
311 }
312 }
313
314 rb := r(b)
315
316 for i := 0; i < 200; i++ {
317 var data string
318 err := rb.ReadString(&data, byte(i), true)
319 if err != nil {
320 t.Error(err)
321 }
322 if data != "hahahahahahahahahahahahahahahahahahahaha" {
323 t.Error("no eq.")
324 }
325 }
326}
327
328func TestBuffer_Reset(t *testing.T) {
329 got := NewBuffer()

Callers

nothing calls this directly

Calls 5

WriteStringMethod · 0.95
NewBufferFunction · 0.85
rFunction · 0.85
ReadStringMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected