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

Function Benchmark_Bind_Cookie

bind_test.go:2155–2180  ·  view source on GitHub ↗

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

(b *testing.B)

Source from the content-addressed store, hash-verified

2153
2154// go test -v -run=^$ -bench=Benchmark_Bind_Cookie -benchmem -count=4
2155func Benchmark_Bind_Cookie(b *testing.B) {
2156 var err error
2157
2158 app := New()
2159 c := app.AcquireCtx(&fasthttp.RequestCtx{})
2160
2161 type Cookie struct {
2162 Name string
2163 Hobby []string
2164 ID int
2165 }
2166 c.Request().SetBody([]byte(``))
2167 c.Request().Header.SetContentType("")
2168
2169 c.Request().Header.SetCookie("id", "1")
2170 c.Request().Header.SetCookie("Name", "John Doe")
2171 c.Request().Header.SetCookie("Hobby", "golang,fiber")
2172
2173 q := new(Cookie)
2174 b.ReportAllocs()
2175
2176 for b.Loop() {
2177 err = c.Bind().Cookie(q)
2178 }
2179 require.NoError(b, err)
2180}
2181
2182// go test -v -run=^$ -bench=Benchmark_Bind_Cookie_Map -benchmem -count=4
2183func Benchmark_Bind_Cookie_Map(b *testing.B) {

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