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

Function Benchmark_Path_matchParams

path_test.go:348–376  ·  view source on GitHub ↗

go test -race -run Test_Path_matchParams

(t *testing.B)

Source from the content-addressed store, hash-verified

346
347// go test -race -run Test_Path_matchParams
348func Benchmark_Path_matchParams(t *testing.B) {
349 var ctxParams [maxParams]string
350 benchCaseFn := func(testCollection routeCaseCollection) {
351 parser := parseRoute(testCollection.pattern, regexp.MustCompile)
352 for _, c := range testCollection.testCases {
353 var matchRes bool
354 state := "match"
355 if !c.match {
356 state = "not match"
357 }
358 t.Run(testCollection.pattern+"_"+state+"_"+c.url, func(b *testing.B) {
359 for b.Loop() {
360 if match := parser.getMatch(c.url, c.url, &ctxParams, c.partialCheck); match {
361 // Get testCases from the original path
362 matchRes = true
363 }
364 }
365 require.Equal(t, c.match, matchRes, "route: '%s', url: '%s'", testCollection.pattern, c.url)
366 if matchRes && len(c.params) > 0 {
367 require.Equal(t, c.params[0:len(c.params)-1], ctxParams[0:len(c.params)-1], "route: '%s', url: '%s'", testCollection.pattern, c.url)
368 }
369 })
370 }
371 }
372
373 for _, testCollection := range benchmarkCases {
374 benchCaseFn(testCollection)
375 }
376}
377
378// go test -race -run Test_RoutePatternMatch
379func Benchmark_ConstraintExecution(b *testing.B) {

Callers

nothing calls this directly

Calls 2

parseRouteFunction · 0.85
getMatchMethod · 0.80

Tested by

no test coverage detected