MCPcopy Index your code
hub / github.com/google/gopacket / benchmarkDecodingLayerParser

Function benchmarkDecodingLayerParser

layers/decode_test.go:208–220  ·  view source on GitHub ↗
(b *testing.B, dlc gopacket.DecodingLayerContainer, ignorePanic bool)

Source from the content-addressed store, hash-verified

206}
207
208func benchmarkDecodingLayerParser(b *testing.B, dlc gopacket.DecodingLayerContainer, ignorePanic bool) {
209 decoded := make([]gopacket.LayerType, 0, 20)
210 dlc = dlc.Put(&Ethernet{})
211 dlc = dlc.Put(&IPv4{})
212 dlc = dlc.Put(&TCP{})
213 dlc = dlc.Put(&gopacket.Payload{})
214 dlp := gopacket.NewDecodingLayerParser(LayerTypeEthernet)
215 dlp.SetDecodingLayerContainer(dlc)
216 dlp.IgnorePanic = ignorePanic
217 for i := 0; i < b.N; i++ {
218 dlp.DecodeLayers(testSimpleTCPPacket, &decoded)
219 }
220}
221
222func BenchmarkDecodingLayerParserSparseIgnorePanic(b *testing.B) {
223 benchmarkDecodingLayerParser(b, gopacket.DecodingLayerSparse(nil), true)

Calls 4

DecodeLayersMethod · 0.95
NewDecodingLayerParserFunction · 0.92
PutMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…