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

Function Benchmark_Route_Match

router_test.go:1748–1773  ·  view source on GitHub ↗

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

(b *testing.B)

Source from the content-addressed store, hash-verified

1746
1747// go test -v ./... -run=^$ -bench=Benchmark_Route_Match -benchmem -count=4
1748func Benchmark_Route_Match(b *testing.B) {
1749 var match bool
1750 var params [maxParams]string
1751
1752 parsed := parseRoute("/user/keys/:id", regexp.MustCompile)
1753 route := &Route{
1754 use: false,
1755 root: false,
1756 star: false,
1757 routeParser: parsed,
1758 Params: parsed.params,
1759 path: "/user/keys/:id",
1760
1761 Path: "/user/keys/:id",
1762 Method: "DELETE",
1763 }
1764 route.Handlers = append(route.Handlers, func(_ Ctx) error {
1765 return nil
1766 })
1767 for b.Loop() {
1768 match = route.match("/user/keys/1337", "/user/keys/1337", &params)
1769 }
1770
1771 require.True(b, match)
1772 require.Equal(b, []string{"1337"}, params[0:len(parsed.params)])
1773}
1774
1775// go test -v ./... -run=^$ -bench=Benchmark_Route_Match_Star -benchmem -count=4
1776func Benchmark_Route_Match_Star(b *testing.B) {

Callers

nothing calls this directly

Calls 2

matchMethod · 0.95
parseRouteFunction · 0.85

Tested by

no test coverage detected