Skip to content

Commit

Permalink
Update Benchmarks for IsTrustedProxy()
Browse files Browse the repository at this point in the history
  • Loading branch information
gaby committed Mar 25, 2024
1 parent f24e0ae commit 7d6d027
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions ctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5786,6 +5786,40 @@ func Benchmark_Ctx_IsProxyTrusted(b *testing.B) {
})
})

// Scenario with trusted proxy check simple
b.Run("WithProxyCheckSimple", func(b *testing.B) {
app := New(Config{
EnableTrustedProxyCheck: true,
})
c := app.AcquireCtx(&fasthttp.RequestCtx{})
c.Request().SetRequestURI("http://google.com/test")
c.Request().Header.Set(HeaderXForwardedHost, "google1.com")
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
c.IsProxyTrusted()
}
app.ReleaseCtx(c)
})

// Scenario with trusted proxy check simple in parallel
b.Run("WithProxyCheckSimpleParallel", func(b *testing.B) {
app := New(Config{
EnableTrustedProxyCheck: true,
})
b.ReportAllocs()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
c := app.AcquireCtx(&fasthttp.RequestCtx{})
c.Request().SetRequestURI("http://google.com/")
c.Request().Header.Set(HeaderXForwardedHost, "google1.com")
for pb.Next() {
c.IsProxyTrusted()
}
app.ReleaseCtx(c)
})
})

// Scenario with trusted proxy check
b.Run("WithProxyCheck", func(b *testing.B) {
app := New(Config{
Expand Down

0 comments on commit 7d6d027

Please sign in to comment.