From ad61ff4af18956525594a9292e88173f6e04957d Mon Sep 17 00:00:00 2001 From: soujanyanmbri <54130357+soujanyanmbri@users.noreply.github.com> Date: Thu, 7 Nov 2024 13:32:29 +0530 Subject: [PATCH] Minor fix --- internal/collections/map_test.go | 7 ------- internal/operators/rx_test.go | 10 ++++++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/internal/collections/map_test.go b/internal/collections/map_test.go index a51d429b4..9bc4f1fcd 100644 --- a/internal/collections/map_test.go +++ b/internal/collections/map_test.go @@ -108,20 +108,15 @@ func TestNewCaseSensitiveKeyMap(t *testing.T) { } func BenchmarkTxSetGet(b *testing.B) { - // Set up the map once outside of the loop c := NewCaseSensitiveKeyMap(variables.RequestHeaders) - - // Benchmark the Set operation b.Run("Set", func(b *testing.B) { for i := 0; i < b.N; i++ { key := fmt.Sprintf("key%d", i) c.Set(key, []string{"value2"}) } }) - // Benchmark the Get operation b.Run("Get", func(b *testing.B) { - // Ensure some values are already set for Get to work for i := 0; i < b.N; i++ { key := fmt.Sprintf("key%d", i) c.Set(key, []string{"value2"}) @@ -132,7 +127,5 @@ func BenchmarkTxSetGet(b *testing.B) { c.Get(key) } }) - - // Report all memory allocations during the benchmark b.ReportAllocs() } diff --git a/internal/operators/rx_test.go b/internal/operators/rx_test.go index e9785713b..580c30608 100644 --- a/internal/operators/rx_test.go +++ b/internal/operators/rx_test.go @@ -119,3 +119,13 @@ func BenchmarkRxSubstringVsMatch(b *testing.B) { rx.FindAllString(str, 3) }) } + +// Benchmark tests for both the original and optimized versions +func BenchmarkMatchesArbitraryBytesOriginal(b *testing.B) { + expr := "\\x41\\x42\\x43\\x44" // Test with a few escape sequences + b.ResetTimer() + + for i := 0; i < b.N; i++ { + matchesArbitraryBytes(expr) + } +}