MCPcopy Create free account
hub / github.com/segmentio/encoding / BenchmarkEncodeMessage

Function BenchmarkEncodeMessage

proto/encode_test.go:61–82  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

59}
60
61func BenchmarkEncodeMessage(b *testing.B) {
62 buf := [128]byte{}
63 msg := &message{
64 A: 1,
65 B: 100,
66 C: 10000,
67 S: submessage{
68 X: "",
69 Y: "Hello World!",
70 },
71 }
72
73 size := Size(msg)
74 data := buf[:size]
75 b.SetBytes(int64(size))
76
77 for range b.N {
78 if _, err := MarshalTo(data, msg); err != nil {
79 b.Fatal(err)
80 }
81 }
82}
83
84func BenchmarkEncodeMap(b *testing.B) {
85 buf := [128]byte{}

Callers

nothing calls this directly

Calls 2

SizeFunction · 0.85
MarshalToFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…