MCPcopy Create free account
hub / github.com/CrowdStrike/csproto / BenchmarkFastDecodeString

Function BenchmarkFastDecodeString

benchmarks_test.go:39–57  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

37}
38
39func BenchmarkFastDecodeString(b *testing.B) {
40 var (
41 // protobuf length-delimited encoding of the string "this is a test"
42 d = []byte{0x12, 0xE, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x74, 0x65, 0x73, 0x74}
43
44 str string
45 )
46 dec := csproto.NewDecoder(d)
47 dec.SetMode(csproto.DecoderModeFast)
48 b.ResetTimer()
49 for n := 0; n < b.N; n++ {
50 dec.Reset()
51 _, _, _ = dec.DecodeTag()
52 s, _ := dec.DecodeString()
53
54 str = s // use s it's not optimized away
55 }
56 _ = str
57}
58
59func BenchmarkDecodeFixed32(b *testing.B) {
60 var (

Callers

nothing calls this directly

Calls 5

SetModeMethod · 0.95
ResetMethod · 0.95
DecodeTagMethod · 0.95
DecodeStringMethod · 0.95
NewDecoderFunction · 0.92

Tested by

no test coverage detected