Skip to content

Commit

Permalink
Add a new benchmark that tests the ctx acquire and release flow
Browse files Browse the repository at this point in the history
this will be used to show differences between version 2 and 3 directly
  • Loading branch information
ReneWerner87 committed Apr 3, 2024
1 parent 799df8e commit 73caafe
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1997,17 +1997,20 @@ func Benchmark_Ctx_AcquireReleaseFlow(b *testing.B) {

fctx := &fasthttp.RequestCtx{}

b.ReportAllocs()
b.ResetTimer()

b.Run("withoutRequestCtx", func(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()

for n := 0; n < b.N; n++ {
c, _ := app.AcquireCtx(fctx).(*DefaultCtx) //nolint:errcheck // not needed
app.ReleaseCtx(c)
}
})

b.Run("withRequestCtx", func(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()

for n := 0; n < b.N; n++ {
c, _ := app.AcquireCtx(&fasthttp.RequestCtx{}).(*DefaultCtx) //nolint:errcheck // not needed
app.ReleaseCtx(c)
Expand Down

0 comments on commit 73caafe

Please sign in to comment.