MCPcopy
hub / github.com/tinylib/msgp / benchBytes

Function benchBytes

msgp/read_test.go:716–732  ·  view source on GitHub ↗
(size uint32, b *testing.B)

Source from the content-addressed store, hash-verified

714}
715
716func benchBytes(size uint32, b *testing.B) {
717 data := make([]byte, 0, size+5)
718 data = AppendBytes(data, RandBytes(int(size)))
719
720 rd := NewReader(NewEndlessReader(data, b))
721 b.SetBytes(int64(len(data)))
722 b.ReportAllocs()
723 b.ResetTimer()
724 var scratch []byte
725 var err error
726 for i := 0; i < b.N; i++ {
727 scratch, err = rd.ReadBytes(scratch)
728 if err != nil {
729 b.Fatal(err)
730 }
731 }
732}
733
734func BenchmarkRead16Bytes(b *testing.B) {
735 benchBytes(16, b)

Callers 3

BenchmarkRead16BytesFunction · 0.85
BenchmarkRead256BytesFunction · 0.85
BenchmarkRead2048BytesFunction · 0.85

Calls 5

ReadBytesMethod · 0.95
AppendBytesFunction · 0.85
RandBytesFunction · 0.85
NewReaderFunction · 0.85
NewEndlessReaderFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…