Skip to content

Commit

Permalink
Add benchmark + Get
Browse files Browse the repository at this point in the history
  • Loading branch information
soujanyanmbri committed Nov 7, 2024
1 parent 8ee2395 commit fd6c77c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/collections/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package collections
import (
"fmt"
"regexp"
"strconv"
"testing"

"github.com/corazawaf/coraza/v3/types/variables"
Expand Down Expand Up @@ -106,3 +107,14 @@ func TestNewCaseSensitiveKeyMap(t *testing.T) {
}

}

func BenchmarkTxGet(b *testing.B) {
c := NewCaseSensitiveKeyMap(variables.RequestHeaders)
for i := 0; i < b.N; i++ {
c.Set("key"+strconv.Itoa(i), []string{"value1", "value2"})
}
// Benchmark the Get method
for i := 0; i < b.N; i++ {
c.Get("key500")
}
}

0 comments on commit fd6c77c

Please sign in to comment.