Home / Function/ Benchmark_Idempotency() — fiber Function Reference

Benchmark_Idempotency() — fiber Function Reference

Architecture documentation for the Benchmark_Idempotency() function in idempotency_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  42071e69_62dd_adf6_73c8_22fd53346177["Benchmark_Idempotency()"]
  94a179ed_b8df_d669_56a8_8e55d7bbb6bf["idempotency_test.go"]
  42071e69_62dd_adf6_73c8_22fd53346177 -->|defined in| 94a179ed_b8df_d669_56a8_8e55d7bbb6bf
  style 42071e69_62dd_adf6_73c8_22fd53346177 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/idempotency/idempotency_test.go lines 135–173

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

	// Needs to be at least a second as the memory storage doesn't support shorter durations.
	const lifetime = 1 * time.Second

	app.Use(New(Config{
		Lifetime: lifetime,
	}))

	app.Post("/", func(_ fiber.Ctx) error {
		return nil
	})

	h := app.Handler()

	b.Run("hit", func(b *testing.B) {
		c := &fasthttp.RequestCtx{}
		c.Request.Header.SetMethod(fiber.MethodPost)
		c.Request.SetRequestURI("/")
		c.Request.Header.Set("X-Idempotency-Key", "00000000-0000-0000-0000-000000000000")

		b.ReportAllocs()
		for b.Loop() {
			h(c)
		}
	})

	b.Run("skip", func(b *testing.B) {
		c := &fasthttp.RequestCtx{}
		c.Request.Header.SetMethod(fiber.MethodPost)
		c.Request.SetRequestURI("/")

		b.ReportAllocs()
		for b.Loop() {
			h(c)
		}
	})
}

Domain

Subdomains

Frequently Asked Questions

What does Benchmark_Idempotency() do?
Benchmark_Idempotency() is a function in the fiber codebase, defined in middleware/idempotency/idempotency_test.go.
Where is Benchmark_Idempotency() defined?
Benchmark_Idempotency() is defined in middleware/idempotency/idempotency_test.go at line 135.

Analyze Your Own Codebase

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

Try Supermodel Free