From d0c8f8c82eef723207366f08cf4acb9f68006932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9?= Date: Wed, 3 Apr 2024 23:16:51 +0200 Subject: [PATCH] Add a new benchmark that tests the ctx acquire and release flow this will be used later to make differences with version 3 directly visible --- app_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app_test.go b/app_test.go index e6adbb72ce..cef3d51706 100644 --- a/app_test.go +++ b/app_test.go @@ -1957,10 +1957,10 @@ 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) @@ -1968,6 +1968,9 @@ func Benchmark_Ctx_AcquireReleaseFlow(b *testing.B) { }) 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)