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

Function BenchmarkString_EncodeMsg

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

Source from the content-addressed store, hash-verified

397}
398
399func BenchmarkString_EncodeMsg(b *testing.B) {
400 sizes := []int{10, 100, 1000}
401
402 for _, size := range sizes {
403 b.Run(fmt.Sprintf("%d", size), func(b *testing.B) {
404 set := make(String)
405 for i := 0; i < size; i++ {
406 set[fmt.Sprintf("val%d", i)] = struct{}{}
407 }
408
409 var buf bytes.Buffer
410 writer := msgp.NewWriter(&buf)
411
412 b.ReportAllocs()
413 b.ResetTimer()
414 for i := 0; i < b.N; i++ {
415 buf.Reset()
416 writer.Reset(&buf)
417 set.EncodeMsg(writer)
418 writer.Flush()
419 }
420 })
421 }
422}
423
424func BenchmarkString_DecodeMsg(b *testing.B) {
425 sizes := []int{10, 100, 1000}

Callers

nothing calls this directly

Calls 5

ResetMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.92
EncodeMsgMethod · 0.65
ResetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…