go test -v -run=^$ -bench=Benchmark_Bind_Cookie_Map -benchmem -count=4
(b *testing.B)
| 2181 | |
| 2182 | // go test -v -run=^$ -bench=Benchmark_Bind_Cookie_Map -benchmem -count=4 |
| 2183 | func 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 |
| 2206 | type customBinder struct{} |