MCPcopy Create free account
hub / github.com/tinylib/msgp / BenchmarkInt8_DecodeMsg

Function BenchmarkInt8_DecodeMsg

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

Source from the content-addressed store, hash-verified

3062}
3063
3064func BenchmarkInt8_DecodeMsg(b *testing.B) {
3065 sizes := []int{10, 100, 1000}
3066
3067 for _, size := range sizes {
3068 b.Run(fmt.Sprintf("%d", size), func(b *testing.B) {
3069 set := make(Int8)
3070 for i := 0; i < size; i++ {
3071 set[int8((i%256)-128)] = struct{}{}
3072 }
3073
3074 var buf bytes.Buffer
3075 writer := msgp.NewWriter(&buf)
3076 set.EncodeMsg(writer)
3077 writer.Flush()
3078 encoded := buf.Bytes()
3079
3080 b.ReportAllocs()
3081 b.ResetTimer()
3082 for i := 0; i < b.N; i++ {
3083 reader := msgp.NewReader(bytes.NewReader(encoded))
3084 var decoded Int8
3085 decoded.DecodeMsg(reader)
3086 }
3087 })
3088 }
3089}
3090
3091func BenchmarkInt8_MarshalMsg(b *testing.B) {
3092 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…