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 later to make differences with version 3 directly visible
  • Loading branch information
ReneWerner87 committed Apr 3, 2024
1 parent f098e2b commit d0c8f8c
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 @@ -1957,17 +1957,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)
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{})
app.ReleaseCtx(c)
Expand Down

0 comments on commit d0c8f8c

Please sign in to comment.