Skip to content

Commit 7d6d027

Browse files
committed
Update Benchmarks for IsTrustedProxy()
1 parent f24e0ae commit 7d6d027

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

ctx_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5786,6 +5786,40 @@ func Benchmark_Ctx_IsProxyTrusted(b *testing.B) {
57865786
})
57875787
})
57885788

5789+
// Scenario with trusted proxy check simple
5790+
b.Run("WithProxyCheckSimple", func(b *testing.B) {
5791+
app := New(Config{
5792+
EnableTrustedProxyCheck: true,
5793+
})
5794+
c := app.AcquireCtx(&fasthttp.RequestCtx{})
5795+
c.Request().SetRequestURI("http://google.com/test")
5796+
c.Request().Header.Set(HeaderXForwardedHost, "google1.com")
5797+
b.ReportAllocs()
5798+
b.ResetTimer()
5799+
for n := 0; n < b.N; n++ {
5800+
c.IsProxyTrusted()
5801+
}
5802+
app.ReleaseCtx(c)
5803+
})
5804+
5805+
// Scenario with trusted proxy check simple in parallel
5806+
b.Run("WithProxyCheckSimpleParallel", func(b *testing.B) {
5807+
app := New(Config{
5808+
EnableTrustedProxyCheck: true,
5809+
})
5810+
b.ReportAllocs()
5811+
b.ResetTimer()
5812+
b.RunParallel(func(pb *testing.PB) {
5813+
c := app.AcquireCtx(&fasthttp.RequestCtx{})
5814+
c.Request().SetRequestURI("http://google.com/")
5815+
c.Request().Header.Set(HeaderXForwardedHost, "google1.com")
5816+
for pb.Next() {
5817+
c.IsProxyTrusted()
5818+
}
5819+
app.ReleaseCtx(c)
5820+
})
5821+
})
5822+
57895823
// Scenario with trusted proxy check
57905824
b.Run("WithProxyCheck", func(b *testing.B) {
57915825
app := New(Config{

0 commit comments

Comments
 (0)