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) + } +}