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

Function Benchmark_Cache_Miss

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

Source from the content-addressed store, hash-verified

3764}
3765
3766func Benchmark_Cache_Miss(b *testing.B) {
3767 app := fiber.New()
3768
3769 app.Use(New())
3770
3771 app.Get("/*", func(c fiber.Ctx) error {
3772 data, _ := os.ReadFile("../../.github/README.md") //nolint:errcheck // We're inside a benchmark
3773 return c.Status(fiber.StatusOK).Send(data)
3774 })
3775
3776 h := app.Handler()
3777
3778 fctx := &fasthttp.RequestCtx{}
3779 fctx.Request.Header.SetMethod(fiber.MethodGet)
3780
3781 b.ReportAllocs()
3782 b.ResetTimer()
3783
3784 var n int
3785 for b.Loop() {
3786 n++
3787 fctx.Request.SetRequestURI("/demo/" + strconv.Itoa(n))
3788 h(fctx)
3789 }
3790
3791 require.Equal(b, fiber.StatusOK, fctx.Response.Header.StatusCode())
3792 require.Greater(b, len(fctx.Response.Body()), 30000)
3793}
3794
3795// go test -v -run=^$ -bench=Benchmark_Cache_Storage -benchmem -count=4
3796func Benchmark_Cache_Storage(b *testing.B) {

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
SendMethod · 0.65
StatusMethod · 0.65
BodyMethod · 0.65
StatusCodeMethod · 0.45

Tested by

no test coverage detected