Home / Function/ Benchmark_Compress() — fiber Function Reference

Benchmark_Compress() — fiber Function Reference

Architecture documentation for the Benchmark_Compress() function in compress_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  14b5e21f_9dd7_be33_79b9_c25050203f2a["Benchmark_Compress()"]
  d6d930a5_a4c6_37a5_5df5_4b38486d6fe6["compress_test.go"]
  14b5e21f_9dd7_be33_79b9_c25050203f2a -->|defined in| d6d930a5_a4c6_37a5_5df5_4b38486d6fe6
  style 14b5e21f_9dd7_be33_79b9_c25050203f2a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/compress/compress_test.go lines 675–711

func Benchmark_Compress(b *testing.B) {
	tests := []struct {
		name           string
		acceptEncoding string
	}{
		{name: "Gzip", acceptEncoding: "gzip"},
		{name: "Deflate", acceptEncoding: "deflate"},
		{name: "Brotli", acceptEncoding: "br"},
		{name: "Zstd", acceptEncoding: "zstd"},
	}

	for _, tt := range tests {
		b.Run(tt.name, func(b *testing.B) {
			app := fiber.New()
			app.Use(New())
			app.Get("/", func(c fiber.Ctx) error {
				c.Set(fiber.HeaderContentType, fiber.MIMETextPlainCharsetUTF8)
				return c.Send(filedata)
			})

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

			if tt.acceptEncoding != "" {
				fctx.Request.Header.Set("Accept-Encoding", tt.acceptEncoding)
			}

			b.ReportAllocs()

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

Domain

Subdomains

Frequently Asked Questions

What does Benchmark_Compress() do?
Benchmark_Compress() is a function in the fiber codebase, defined in middleware/compress/compress_test.go.
Where is Benchmark_Compress() defined?
Benchmark_Compress() is defined in middleware/compress/compress_test.go at line 675.

Analyze Your Own Codebase

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

Try Supermodel Free