MCPcopy
hub / github.com/gofiber/fiber / Benchmark_Bind_Cookie_Map

Function Benchmark_Bind_Cookie_Map

bind_test.go:2183–2203  ·  view source on GitHub ↗

go test -v -run=^$ -bench=Benchmark_Bind_Cookie_Map -benchmem -count=4

(b *testing.B)

Source from the content-addressed store, hash-verified

2181
2182// go test -v -run=^$ -bench=Benchmark_Bind_Cookie_Map -benchmem -count=4
2183func Benchmark_Bind_Cookie_Map(b *testing.B) {
2184 var err error
2185
2186 app := New()
2187 c := app.AcquireCtx(&fasthttp.RequestCtx{})
2188
2189 c.Request().SetBody([]byte(``))
2190 c.Request().Header.SetContentType("")
2191
2192 c.Request().Header.SetCookie("id", "1")
2193 c.Request().Header.SetCookie("Name", "John Doe")
2194 c.Request().Header.SetCookie("Hobby", "golang,fiber")
2195
2196 q := make(map[string][]string)
2197 b.ReportAllocs()
2198
2199 for b.Loop() {
2200 err = c.Bind().Cookie(&q)
2201 }
2202 require.NoError(b, err)
2203}
2204
2205// custom binder for testing
2206type customBinder struct{}

Callers

nothing calls this directly

Calls 6

AcquireCtxMethod · 0.80
NewFunction · 0.70
RequestMethod · 0.65
CookieMethod · 0.65
BindMethod · 0.65
SetCookieMethod · 0.45

Tested by

no test coverage detected