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

Function BenchmarkInt32_DecodeMsg

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

Source from the content-addressed store, hash-verified

5702}
5703
5704func BenchmarkInt32_DecodeMsg(b *testing.B) {
5705 sizes := []int{10, 100, 1000}
5706
5707 for _, size := range sizes {
5708 b.Run(fmt.Sprintf("%d", size), func(b *testing.B) {
5709 set := make(Int32)
5710 for i := 0; i < size; i++ {
5711 set[int32(i)] = struct{}{}
5712 }
5713
5714 var buf bytes.Buffer
5715 writer := msgp.NewWriter(&buf)
5716 set.EncodeMsg(writer)
5717 writer.Flush()
5718 encoded := buf.Bytes()
5719
5720 b.ReportAllocs()
5721 b.ResetTimer()
5722 for i := 0; i < b.N; i++ {
5723 reader := msgp.NewReader(bytes.NewReader(encoded))
5724 var decoded Int32
5725 decoded.DecodeMsg(reader)
5726 }
5727 })
5728 }
5729}
5730
5731func BenchmarkInt32_MarshalMsg(b *testing.B) {
5732 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…