go test -v -run=^$ -bench=Benchmark_Cache_Storage -benchmem -count=4
(b *testing.B)
| 3794 | |
| 3795 | // go test -v -run=^$ -bench=Benchmark_Cache_Storage -benchmem -count=4 |
| 3796 | func Benchmark_Cache_Storage(b *testing.B) { |
| 3797 | app := fiber.New() |
| 3798 | |
| 3799 | app.Use(New(Config{ |
| 3800 | Storage: memory.New(), |
| 3801 | })) |
| 3802 | |
| 3803 | app.Get("/demo", func(c fiber.Ctx) error { |
| 3804 | data, _ := os.ReadFile("../../.github/README.md") //nolint:errcheck // We're inside a benchmark |
| 3805 | return c.Status(fiber.StatusTeapot).Send(data) |
| 3806 | }) |
| 3807 | |
| 3808 | h := app.Handler() |
| 3809 | |
| 3810 | fctx := &fasthttp.RequestCtx{} |
| 3811 | fctx.Request.Header.SetMethod(fiber.MethodGet) |
| 3812 | fctx.Request.SetRequestURI("/demo") |
| 3813 | |
| 3814 | b.ReportAllocs() |
| 3815 | |
| 3816 | for b.Loop() { |
| 3817 | h(fctx) |
| 3818 | } |
| 3819 | |
| 3820 | require.Equal(b, fiber.StatusTeapot, fctx.Response.Header.StatusCode()) |
| 3821 | require.Greater(b, len(fctx.Response.Body()), 30000) |
| 3822 | } |
| 3823 | |
| 3824 | func Benchmark_Cache_AdditionalHeaders(b *testing.B) { |
| 3825 | app := fiber.New() |