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

Function BenchmarkInt16Sorted_DecodeMsg

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

Source from the content-addressed store, hash-verified

4519}
4520
4521func BenchmarkInt16Sorted_DecodeMsg(b *testing.B) {
4522 sizes := []int{10, 100, 1000}
4523
4524 for _, size := range sizes {
4525 b.Run(fmt.Sprintf("%d", size), func(b *testing.B) {
4526 set := make(Int16Sorted)
4527 for i := 0; i < size; i++ {
4528 set[int16((i%65536)-32768)] = struct{}{}
4529 }
4530
4531 var buf bytes.Buffer
4532 writer := msgp.NewWriter(&buf)
4533 set.EncodeMsg(writer)
4534 writer.Flush()
4535 encoded := buf.Bytes()
4536
4537 b.ReportAllocs()
4538 b.ResetTimer()
4539 for i := 0; i < b.N; i++ {
4540 reader := msgp.NewReader(bytes.NewReader(encoded))
4541 var decoded Int16Sorted
4542 decoded.DecodeMsg(reader)
4543 }
4544 })
4545 }
4546}
4547
4548func BenchmarkInt16Sorted_MarshalMsg(b *testing.B) {
4549 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…