outlet/flow: add benchmark for bidir flows

This commit is contained in:
Vincent Bernat
2025-09-29 05:16:45 +02:00
parent 73d005d229
commit dfa5db15fe

View File

@@ -315,6 +315,32 @@ func BenchmarkDecodeNetFlow(b *testing.B) {
}
}
func BenchmarkDecodeBidirNetFlow(b *testing.B) {
schema.DisableDebug(b)
r := reporter.NewMock(b)
sch := schema.NewMock(b)
bf := sch.NewFlowMessage()
finalize := func() {}
nfdecoder := netflow.New(r, decoder.Dependencies{Schema: sch})
options := decoder.Option{TimestampSource: pb.RawFlow_TS_INPUT}
template := helpers.ReadPcapL4(b,
filepath.Join("decoder", "netflow", "testdata", "ipfixprobe-templates.pcap"))
_, err := nfdecoder.Decode(
decoder.RawFlow{Payload: template, Source: netip.MustParseAddr("::ffff:127.0.0.1")},
options, bf, finalize)
if err != nil {
b.Fatalf("Decode() error on options template:\n%+v", err)
}
data := helpers.ReadPcapL4(b, filepath.Join("decoder", "netflow", "testdata", "ipfixprobe-data.pcap"))
for b.Loop() {
nfdecoder.Decode(
decoder.RawFlow{Payload: data, Source: netip.MustParseAddr("::ffff:127.0.0.1")},
options, bf, finalize)
}
}
func BenchmarkDecodeSflow(b *testing.B) {
schema.DisableDebug(b)
r := reporter.NewMock(b)