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

Function Benchmark_Router_NotFound

router_test.go:1532–1550  ·  view source on GitHub ↗

go test -v ./... -run=^$ -bench=Benchmark_Router_NotFound -benchmem -count=4

(b *testing.B)

Source from the content-addressed store, hash-verified

1530
1531// go test -v ./... -run=^$ -bench=Benchmark_Router_NotFound -benchmem -count=4
1532func Benchmark_Router_NotFound(b *testing.B) {
1533 b.ReportAllocs()
1534 app := New()
1535 app.Use(func(c Ctx) error {
1536 return c.Next()
1537 })
1538 registerDummyRoutes(app)
1539 appHandler := app.Handler()
1540 c := &fasthttp.RequestCtx{}
1541
1542 c.Request.Header.SetMethod("DELETE")
1543 c.URI().SetPath("/this/route/does/not/exist")
1544
1545 for b.Loop() {
1546 appHandler(c)
1547 }
1548 require.Equal(b, 404, c.Response.StatusCode())
1549 require.Equal(b, "Not Found", string(c.Response.Body()))
1550}
1551
1552// go test -v ./... -run=^$ -bench=Benchmark_Router_Handler -benchmem -count=4
1553func Benchmark_Router_Handler(b *testing.B) {

Callers

nothing calls this directly

Calls 10

registerDummyRoutesFunction · 0.85
HandlerMethod · 0.80
SetMethodMethod · 0.80
SetPathMethod · 0.80
URIMethod · 0.80
NewFunction · 0.70
UseMethod · 0.65
NextMethod · 0.65
BodyMethod · 0.65
StatusCodeMethod · 0.45

Tested by

no test coverage detected