1
0
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:
Tyler Bunnell
2015-09-11 16:23:57 -06:00
parent 33eb3fb67b
commit 4f3335aac7
2 changed files with 36 additions and 2 deletions

View File

@@ -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)
}
}