From f07e2070b87600366d394f46d2643b955e3ecd12 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sun, 5 Feb 2023 12:33:10 +0100 Subject: [PATCH] inlet/flow: more elegant way to build titles for protobuf bench --- inlet/flow/decoder_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/inlet/flow/decoder_test.go b/inlet/flow/decoder_test.go index 5336adad..9432bb14 100644 --- a/inlet/flow/decoder_test.go +++ b/inlet/flow/decoder_test.go @@ -42,10 +42,10 @@ func BenchmarkDecodeEncodeNetflow(b *testing.B) { data = helpers.ReadPcapPayload(b, filepath.Join("decoder", "netflow", "testdata", "data-260.pcap")) for _, withEncoding := range []bool{true, false} { - title := "with encoding" - if !withEncoding { - title = "without encoding" - } + title := map[bool]string{ + true: "with encoding", + false: "without encoding", + }[withEncoding] b.Run(title, func(b *testing.B) { for i := 0; i < b.N; i++ { got = nfdecoder.Decode(decoder.RawFlow{Payload: data, Source: net.ParseIP("127.0.0.1")}) @@ -70,10 +70,10 @@ func BenchmarkDecodeEncodeSflow(b *testing.B) { data := helpers.ReadPcapPayload(b, filepath.Join("decoder", "sflow", "testdata", "data-1140.pcap")) for _, withEncoding := range []bool{true, false} { - title := "with encoding" - if !withEncoding { - title = "without encoding" - } + title := map[bool]string{ + true: "with encoding", + false: "without encoding", + }[withEncoding] var got []*schema.FlowMessage b.Run(title, func(b *testing.B) { for i := 0; i < b.N; i++ {