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

Function BenchmarkScan

proto/message_test.go:166–199  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

164}
165
166func BenchmarkScan(b *testing.B) {
167 m, _ := Marshal(&message{
168 A: 1,
169 B: 2,
170 C: 3,
171 S: submessage{
172 X: "hello",
173 Y: "world",
174 },
175 })
176
177 for range b.N {
178 Scan(m, func(f FieldNumber, t WireType, v RawValue) (bool, error) {
179 switch f {
180 case 1, 2, 3:
181 return true, nil
182 case 4:
183 err := Scan(v, func(f FieldNumber, t WireType, v RawValue) (bool, error) {
184 switch f {
185 case 1, 2:
186 return true, nil
187 default:
188 b.Error("invalid field number:", f)
189 return false, nil
190 }
191 })
192 return err != nil, err
193 default:
194 b.Error("invalid field number:", f)
195 return false, nil
196 }
197 })
198 }
199}

Callers

nothing calls this directly

Calls 3

ScanFunction · 0.85
MarshalFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…