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

Function Benchmark_Ctx_Get_Location_From_Route

ctx_test.go:8105–8122  ·  view source on GitHub ↗

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

(b *testing.B)

Source from the content-addressed store, hash-verified

8103
8104// go test -v -run=^$ -bench=Benchmark_Ctx_Get_Location_From_Route -benchmem -count=4
8105func Benchmark_Ctx_Get_Location_From_Route(b *testing.B) {
8106 app := New()
8107 c := app.AcquireCtx(&fasthttp.RequestCtx{}).(*DefaultCtx) //nolint:errcheck,forcetypeassert // not needed
8108
8109 app.Get("/user/:name", func(c Ctx) error {
8110 return c.SendString(c.Params("name"))
8111 }).Name("User")
8112
8113 var err error
8114 var location string
8115 for b.Loop() {
8116 route := app.GetRoute("User")
8117 location, err = c.getLocationFromRoute(&route, Map{"name": "fiber"})
8118 }
8119
8120 require.Equal(b, "/user/fiber", location)
8121 require.NoError(b, err)
8122}
8123
8124// go test -run Test_Ctx_Get_Location_From_Route_name
8125func Test_Ctx_Get_Location_From_Route_name(t *testing.T) {

Callers

nothing calls this directly

Calls 8

AcquireCtxMethod · 0.80
GetRouteMethod · 0.80
NewFunction · 0.70
NameMethod · 0.65
GetMethod · 0.65
SendStringMethod · 0.65
ParamsMethod · 0.65
getLocationFromRouteMethod · 0.65

Tested by

no test coverage detected