From 956f915f772a754c889e545ef352fbc563cf7f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 13 Jan 2025 12:57:48 +0200 Subject: [PATCH] tpl/collections: Add BenchmarkWhereMap --- tpl/collections/where_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tpl/collections/where_test.go b/tpl/collections/where_test.go index 7ec9572e05e..c66a5d6089b 100644 --- a/tpl/collections/where_test.go +++ b/tpl/collections/where_test.go @@ -902,3 +902,19 @@ func BenchmarkWhereOps(b *testing.B) { } }) } + +func BenchmarkWhereMap(b *testing.B) { + ns := newNs() + seq := map[string]string{} + + for i := 0; i < 1000; i++ { + seq[fmt.Sprintf("key%d", i)] = "value" + } + + for i := 0; i < b.N; i++ { + _, err := ns.Where(context.Background(), seq, "key", "eq", "value") + if err != nil { + b.Fatal(err) + } + } +}