MCPcopy Index your code
hub / github.com/tinylib/msgp / benchString

Function benchString

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

Source from the content-addressed store, hash-verified

779}
780
781func benchString(size uint32, b *testing.B) {
782 str := string(RandBytes(int(size)))
783 data := make([]byte, 0, len(str)+5)
784 data = AppendString(data, str)
785 rd := NewReader(NewEndlessReader(data, b))
786 b.SetBytes(int64(len(data)))
787 b.ReportAllocs()
788 b.ResetTimer()
789 for i := 0; i < b.N; i++ {
790 _, err := rd.ReadString()
791 if err != nil {
792 b.Fatal(err)
793 }
794 }
795}
796
797func benchStringAsBytes(size uint32, b *testing.B) {
798 str := string(RandBytes(int(size)))

Callers 2

BenchmarkRead16StringFunction · 0.85
BenchmarkRead256StringFunction · 0.85

Calls 5

ReadStringMethod · 0.95
RandBytesFunction · 0.85
AppendStringFunction · 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…