MCPcopy Index your code
hub / github.com/labstack/echo / BenchmarkDecompress

Function BenchmarkDecompress

middleware/decompress_test.go:214–235  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

212}
213
214func 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
237func gzipString(body string) ([]byte, error) {
238 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 6

ResponseMethod · 0.95
gzipStringFunction · 0.85
DecompressFunction · 0.85
SetMethod · 0.80
NewContextMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…