From cd91345b76020bca3fe64c9611c2d6b58952ac5d Mon Sep 17 00:00:00 2001 From: Oleg Zaytsev Date: Mon, 2 Oct 2023 12:00:18 +0200 Subject: [PATCH] Fix BenchmarkOptimizeEqualStringMatchers The logic has changed, and we create a slice-based matcher for smaller number of alternations. This fixes the benchmark. Signed-off-by: Oleg Zaytsev --- model/labels/regexp_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/model/labels/regexp_test.go b/model/labels/regexp_test.go index 123f2f19bb..a06fff4abe 100644 --- a/model/labels/regexp_test.go +++ b/model/labels/regexp_test.go @@ -1183,7 +1183,11 @@ func BenchmarkOptimizeEqualStringMatchers(b *testing.B) { require.IsType(b, orStringMatcher{}, unoptimized) optimized := optimizeEqualStringMatchers(unoptimized, 0) - require.IsType(b, &equalMultiStringMapMatcher{}, optimized) + if numAlternations < minEqualMultiStringMatcherMapThreshold { + require.IsType(b, &equalMultiStringSliceMatcher{}, optimized) + } else { + require.IsType(b, &equalMultiStringMapMatcher{}, optimized) + } b.Run("without optimizeEqualStringMatchers()", func(b *testing.B) { for n := 0; n < b.N; n++ {