From 9f8eb08788d9b54e23faa211983f2f7e702a6396 Mon Sep 17 00:00:00 2001 From: Smirnov Oleksandr Date: Thu, 19 Sep 2024 23:16:01 +0300 Subject: [PATCH] test(reqid): add banch --- internal/transport/http/reqid/reqid_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/transport/http/reqid/reqid_test.go b/internal/transport/http/reqid/reqid_test.go index 0064b90..48ba99c 100644 --- a/internal/transport/http/reqid/reqid_test.go +++ b/internal/transport/http/reqid/reqid_test.go @@ -33,3 +33,17 @@ func TestMiddleware(t *testing.T) { assert.Equal(t, http.StatusOK, w.Code) assert.NotEmpty(t, w.Header().Get(headerRequestID)) } + +func BenchmarkMiddleware(b *testing.B) { + r := gin.New() + r.Use(Middleware()) + r.GET("/", testHandler) + + w := httptest.NewRecorder() + req, err := http.NewRequest(http.MethodGet, "/", nil) + require.NoError(b, err) + + for i := 0; i < b.N; i++ { + r.ServeHTTP(w, req) + } +}