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

Function BenchmarkInt_DecodeMsg

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

Source from the content-addressed store, hash-verified

1082}
1083
1084func BenchmarkInt_DecodeMsg(b *testing.B) {
1085 sizes := []int{10, 100, 1000}
1086
1087 for _, size := range sizes {
1088 b.Run(fmt.Sprintf("%d", size), func(b *testing.B) {
1089 set := make(Int)
1090 for i := 0; i < size; i++ {
1091 set[int(i)] = struct{}{}
1092 }
1093
1094 var buf bytes.Buffer
1095 writer := msgp.NewWriter(&buf)
1096 set.EncodeMsg(writer)
1097 writer.Flush()
1098 encoded := buf.Bytes()
1099
1100 b.ReportAllocs()
1101 b.ResetTimer()
1102 for i := 0; i < b.N; i++ {
1103 reader := msgp.NewReader(bytes.NewReader(encoded))
1104 var decoded Int
1105 decoded.DecodeMsg(reader)
1106 }
1107 })
1108 }
1109}
1110
1111func BenchmarkInt_MarshalMsg(b *testing.B) {
1112 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…