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

Function Benchmark_App_MethodNotAllowed

router_test.go:1510–1529  ·  view source on GitHub ↗

go test -v -run=^$ -bench=Benchmark_App_MethodNotAllowed -benchmem -count=4

(b *testing.B)

Source from the content-addressed store, hash-verified

1508
1509// go test -v -run=^$ -bench=Benchmark_App_MethodNotAllowed -benchmem -count=4
1510func Benchmark_App_MethodNotAllowed(b *testing.B) {
1511 app := New()
1512 h := func(c Ctx) error {
1513 return c.SendString("Hello World!")
1514 }
1515 app.All("/this/is/a/", h)
1516 app.Get("/this/is/a/dummy/route/oke", h)
1517 appHandler := app.Handler()
1518 c := &fasthttp.RequestCtx{}
1519
1520 c.Request.Header.SetMethod("DELETE")
1521 c.URI().SetPath("/this/is/a/dummy/route/oke")
1522
1523 for b.Loop() {
1524 appHandler(c)
1525 }
1526 require.Equal(b, 405, c.Response.StatusCode())
1527 require.Equal(b, MethodGet+", "+MethodHead, string(c.Response.Header.Peek("Allow")))
1528 require.Equal(b, utils.StatusMessage(StatusMethodNotAllowed), string(c.Response.Body()))
1529}
1530
1531// go test -v ./... -run=^$ -bench=Benchmark_Router_NotFound -benchmem -count=4
1532func Benchmark_Router_NotFound(b *testing.B) {

Callers

nothing calls this directly

Calls 10

HandlerMethod · 0.80
SetMethodMethod · 0.80
SetPathMethod · 0.80
URIMethod · 0.80
NewFunction · 0.70
SendStringMethod · 0.65
AllMethod · 0.65
GetMethod · 0.65
BodyMethod · 0.65
StatusCodeMethod · 0.45

Tested by

no test coverage detected