(b *testing.B)
| 212 | } |
| 213 | |
| 214 | func BenchmarkDecompress(b *testing.B) { |
| 215 | e := echo.New() |
| 216 | body := `{"name": "echo"}` |
| 217 | gz, _ := gzipString(body) |
| 218 | |
| 219 | h := Decompress()(func(c *echo.Context) error { |
| 220 | c.Response().Write([]byte(body)) // For Content-Type sniffing |
| 221 | return nil |
| 222 | }) |
| 223 | |
| 224 | b.ReportAllocs() |
| 225 | b.ResetTimer() |
| 226 | |
| 227 | for i := 0; i < b.N; i++ { |
| 228 | // Decompress |
| 229 | req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(gz)) |
| 230 | req.Header.Set(echo.HeaderContentEncoding, GZIPEncoding) |
| 231 | rec := httptest.NewRecorder() |
| 232 | c := e.NewContext(req, rec) |
| 233 | h(c) |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | func gzipString(body string) ([]byte, error) { |
| 238 | var buf bytes.Buffer |
nothing calls this directly
no test coverage detected
searching dependent graphs…