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

Function BenchmarkInt_EncodeMsg

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

Source from the content-addressed store, hash-verified

1057}
1058
1059func BenchmarkInt_EncodeMsg(b *testing.B) {
1060 sizes := []int{10, 100, 1000}
1061
1062 for _, size := range sizes {
1063 b.Run(fmt.Sprintf("%d", size), func(b *testing.B) {
1064 set := make(Int)
1065 for i := 0; i < size; i++ {
1066 set[int(i)] = struct{}{}
1067 }
1068
1069 var buf bytes.Buffer
1070 writer := msgp.NewWriter(&buf)
1071
1072 b.ReportAllocs()
1073 b.ResetTimer()
1074 for i := 0; i < b.N; i++ {
1075 buf.Reset()
1076 writer.Reset(&buf)
1077 set.EncodeMsg(writer)
1078 writer.Flush()
1079 }
1080 })
1081 }
1082}
1083
1084func BenchmarkInt_DecodeMsg(b *testing.B) {
1085 sizes := []int{10, 100, 1000}

Callers

nothing calls this directly

Calls 5

ResetMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.92
EncodeMsgMethod · 0.65
ResetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…