mirror of
https://github.com/labstack/echo.git
synced 2025-12-01 22:51:17 +02:00
Add sync.Pool to gzip middleware
This commit is contained in:
@@ -119,3 +119,25 @@ func TestGzipCloseNotify(t *testing.T) {
|
||||
|
||||
assert.Equal(t, closed, true)
|
||||
}
|
||||
|
||||
func BenchmarkGzip(b *testing.B) {
|
||||
|
||||
b.StopTimer()
|
||||
b.ReportAllocs()
|
||||
|
||||
h := func(c *echo.Context) error {
|
||||
c.Response().Write([]byte("test")) // For Content-Type sniffing
|
||||
return nil
|
||||
}
|
||||
req, _ := http.NewRequest(echo.GET, "/", nil)
|
||||
req.Header.Set(echo.AcceptEncoding, "gzip")
|
||||
|
||||
b.StartTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
rec := httptest.NewRecorder()
|
||||
c := echo.NewContext(req, echo.NewResponse(rec), echo.New())
|
||||
Gzip()(h)(c)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user