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

Function BenchmarkStringSorted_DecodeMsg

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

Source from the content-addressed store, hash-verified

559}
560
561func BenchmarkStringSorted_DecodeMsg(b *testing.B) {
562 sizes := []int{10, 100, 1000}
563
564 for _, size := range sizes {
565 b.Run(fmt.Sprintf("%d", size), func(b *testing.B) {
566 set := make(StringSorted)
567 for i := 0; i < size; i++ {
568 set[fmt.Sprintf("val%d", i)] = struct{}{}
569 }
570
571 var buf bytes.Buffer
572 writer := msgp.NewWriter(&buf)
573 set.EncodeMsg(writer)
574 writer.Flush()
575 encoded := buf.Bytes()
576
577 b.ReportAllocs()
578 b.ResetTimer()
579 for i := 0; i < b.N; i++ {
580 reader := msgp.NewReader(bytes.NewReader(encoded))
581 var decoded StringSorted
582 decoded.DecodeMsg(reader)
583 }
584 })
585 }
586}
587
588func BenchmarkStringSorted_MarshalMsg(b *testing.B) {
589 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…