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

Function BenchmarkLocate

msgp/edit_test.go:178–199  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

176}
177
178func BenchmarkLocate(b *testing.B) {
179 var buf bytes.Buffer
180 en := NewWriter(&buf)
181 en.WriteMapHeader(3)
182 en.WriteString("thing_one")
183 en.WriteString("value_one")
184 en.WriteString("thing_two")
185 en.WriteFloat64(2.0)
186 en.WriteString("thing_three")
187 en.WriteBytes([]byte("hello!"))
188 en.Flush()
189
190 raw := buf.Bytes()
191 // bytes/s will be the number of bytes traversed per unit of time
192 field := Locate("thing_three", raw)
193 b.SetBytes(int64(len(raw) - len(field)))
194 b.ReportAllocs()
195 b.ResetTimer()
196 for i := 0; i < b.N; i++ {
197 Locate("thing_three", raw)
198 }
199}

Callers

nothing calls this directly

Calls 7

WriteMapHeaderMethod · 0.95
WriteStringMethod · 0.95
WriteFloat64Method · 0.95
WriteBytesMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.85
LocateFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…