Files
fiber/bench/go.mod
d94425b64f bench: router match/registration suite + BENCHMARKS.md (#3)
Prove the specificity-routing fork's performance on a representative
~70-route Hanzo cloud table (static, param, multi-param, wildcard).

- router_bench_test.go: match hot-path (app.next, 0-alloc), full dispatch,
  registration scaling (N=10/70/500/1000), and a Go 1.22 net/http.ServeMux
  routing + registration baseline, with precedence-correctness gates
  (static/param beat wildcard; fork agrees with ServeMux on every request).
- bench/: separate module (own go.mod, replace ../) that isolates the upstream
  gofiber/fiber v3.2.0 dependency — fork vs upstream match (per-route +
  aggregate sweep) and registration. Never pollutes the fork's own module.
- middleware/static: embed.FS serve benchmark (small 1 KiB + medium 64 KiB).
- BENCHMARKS.md: methodology (M1 Max, go1.26.4, -benchtime=1s -count=6,
  benchstat medians) and the real numbers.

Findings: the fork adds ZERO aggregate match cost (sweep 10.77us vs upstream
10.96us; per-route latency is a scan-order permutation, not a regression);
fiber routing is 0-alloc vs ServeMux's 1-5 allocs per dynamic route;
registration is O(n^2) (9.5ms at N=1000/method, <110us at N<=70) — the one
honest regression, and fixable with an index-based conflict check.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-11 05:06:59 -07:00

32 lines
1.1 KiB
AMPL

// Benchmark-only module: isolates the upstream gofiber/fiber v3.2.0 dependency
// so the fork's own module (../) never takes a dep on the package it forked.
// Run: cd bench && go test -bench=. -benchmem -count=6 .
module github.com/zap-proto/fiber/bench
go 1.25.0
require (
github.com/gofiber/fiber/v3 v3.2.0
github.com/valyala/fasthttp v1.70.0
github.com/zap-proto/fiber/v3 v3.2.1
)
require (
github.com/andybalholm/brotli v1.2.1 // indirect
github.com/gofiber/schema v1.7.1 // indirect
github.com/gofiber/utils/v2 v2.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/klauspost/compress v1.18.5 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.21 // indirect
github.com/philhofer/fwd v1.2.0 // indirect
github.com/tinylib/msgp v1.6.4 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
golang.org/x/crypto v0.50.0 // indirect
golang.org/x/net v0.53.0 // indirect
golang.org/x/sys v0.43.0 // indirect
golang.org/x/text v0.36.0 // indirect
)
replace github.com/zap-proto/fiber/v3 => ../