Home / Function/ Benchmark_Cache() — fiber Function Reference

Benchmark_Cache() — fiber Function Reference

Architecture documentation for the Benchmark_Cache() function in cache_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  4ea6069b_a6b4_4c08_4e1d_f1250c5cad64["Benchmark_Cache()"]
  8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"]
  4ea6069b_a6b4_4c08_4e1d_f1250c5cad64 -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656
  style 4ea6069b_a6b4_4c08_4e1d_f1250c5cad64 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/cache/cache_test.go lines 3297–3321

func Benchmark_Cache(b *testing.B) {
	app := fiber.New()

	app.Use(New())

	app.Get("/demo", func(c fiber.Ctx) error {
		data, _ := os.ReadFile("../../.github/README.md") //nolint:errcheck // We're inside a benchmark
		return c.Status(fiber.StatusTeapot).Send(data)
	})

	h := app.Handler()

	fctx := &fasthttp.RequestCtx{}
	fctx.Request.Header.SetMethod(fiber.MethodGet)
	fctx.Request.SetRequestURI("/demo")

	b.ReportAllocs()

	for b.Loop() {
		h(fctx)
	}

	require.Equal(b, fiber.StatusTeapot, fctx.Response.Header.StatusCode())
	require.Greater(b, len(fctx.Response.Body()), 30000)
}

Subdomains

Frequently Asked Questions

What does Benchmark_Cache() do?
Benchmark_Cache() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is Benchmark_Cache() defined?
Benchmark_Cache() is defined in middleware/cache/cache_test.go at line 3297.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free