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

Function BenchmarkInt16_DecodeMsg

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

Source from the content-addressed store, hash-verified

4382}
4383
4384func BenchmarkInt16_DecodeMsg(b *testing.B) {
4385 sizes := []int{10, 100, 1000}
4386
4387 for _, size := range sizes {
4388 b.Run(fmt.Sprintf("%d", size), func(b *testing.B) {
4389 set := make(Int16)
4390 for i := 0; i < size; i++ {
4391 set[int16((i%65536)-32768)] = struct{}{}
4392 }
4393
4394 var buf bytes.Buffer
4395 writer := msgp.NewWriter(&buf)
4396 set.EncodeMsg(writer)
4397 writer.Flush()
4398 encoded := buf.Bytes()
4399
4400 b.ReportAllocs()
4401 b.ResetTimer()
4402 for i := 0; i < b.N; i++ {
4403 reader := msgp.NewReader(bytes.NewReader(encoded))
4404 var decoded Int16
4405 decoded.DecodeMsg(reader)
4406 }
4407 })
4408 }
4409}
4410
4411func BenchmarkInt16_MarshalMsg(b *testing.B) {
4412 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…