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

Function BenchmarkIntSorted_DecodeMsg

msgp/setof/generated_test.go:1221–1246  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

1219}
1220
1221func BenchmarkIntSorted_DecodeMsg(b *testing.B) {
1222 sizes := []int{10, 100, 1000}
1223
1224 for _, size := range sizes {
1225 b.Run(fmt.Sprintf("%d", size), func(b *testing.B) {
1226 set := make(IntSorted)
1227 for i := 0; i < size; i++ {
1228 set[int(i)] = struct{}{}
1229 }
1230
1231 var buf bytes.Buffer
1232 writer := msgp.NewWriter(&buf)
1233 set.EncodeMsg(writer)
1234 writer.Flush()
1235 encoded := buf.Bytes()
1236
1237 b.ReportAllocs()
1238 b.ResetTimer()
1239 for i := 0; i < b.N; i++ {
1240 reader := msgp.NewReader(bytes.NewReader(encoded))
1241 var decoded IntSorted
1242 decoded.DecodeMsg(reader)
1243 }
1244 })
1245 }
1246}
1247
1248func BenchmarkIntSorted_MarshalMsg(b *testing.B) {
1249 sizes := []int{10, 100, 1000}

Callers

nothing calls this directly

Calls 5

FlushMethod · 0.95
DecodeMsgMethod · 0.95
NewWriterFunction · 0.92
NewReaderFunction · 0.92
EncodeMsgMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…