(b *testing.B)
| 37 | } |
| 38 | |
| 39 | func 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 | |
| 59 | func BenchmarkDecodeFixed32(b *testing.B) { |
| 60 | var ( |
nothing calls this directly
no test coverage detected