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

Function Benchmark_Cache_AdditionalHeaders

middleware/cache/cache_test.go:3824–3849  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

3822}
3823
3824func Benchmark_Cache_AdditionalHeaders(b *testing.B) {
3825 app := fiber.New()
3826 app.Use(New(Config{
3827 StoreResponseHeaders: true,
3828 }))
3829
3830 app.Get("/demo", func(c fiber.Ctx) error {
3831 c.Response().Header.Add("X-Foobar", "foobar")
3832 return c.SendStatus(418)
3833 })
3834
3835 h := app.Handler()
3836
3837 fctx := &fasthttp.RequestCtx{}
3838 fctx.Request.Header.SetMethod(fiber.MethodGet)
3839 fctx.Request.SetRequestURI("/demo")
3840
3841 b.ReportAllocs()
3842
3843 for b.Loop() {
3844 h(fctx)
3845 }
3846
3847 require.Equal(b, fiber.StatusTeapot, fctx.Response.Header.StatusCode())
3848 require.Equal(b, []byte("foobar"), fctx.Response.Header.Peek("X-Foobar"))
3849}
3850
3851func Benchmark_Cache_QueryMethod(b *testing.B) {
3852 app := fiber.New()

Callers

nothing calls this directly

Calls 10

HandlerMethod · 0.80
SetMethodMethod · 0.80
NewFunction · 0.70
NewMethod · 0.65
UseMethod · 0.65
GetMethod · 0.65
AddMethod · 0.65
ResponseMethod · 0.65
SendStatusMethod · 0.65
StatusCodeMethod · 0.45

Tested by

no test coverage detected