(b *testing.B)
| 2270 | } |
| 2271 | |
| 2272 | func Benchmark_Route_Match_Parallel(b *testing.B) { |
| 2273 | parsed := parseRoute("/user/keys/:id", regexp.MustCompile) |
| 2274 | route := &Route{use: false, root: false, star: false, routeParser: parsed, Params: parsed.params, path: "/user/keys/:id", Path: "/user/keys/:id", Method: "DELETE"} |
| 2275 | route.Handlers = append(route.Handlers, func(_ Ctx) error { |
| 2276 | return nil |
| 2277 | }) |
| 2278 | b.RunParallel(func(pb *testing.PB) { |
| 2279 | // Each worker gets its own local variables to avoid data races |
| 2280 | var params [maxParams]string |
| 2281 | for pb.Next() { |
| 2282 | _ = route.match("/user/keys/1337", "/user/keys/1337", ¶ms) |
| 2283 | } |
| 2284 | }) |
| 2285 | |
| 2286 | // Single-threaded verification to preserve correctness checks |
| 2287 | var verifyParams [maxParams]string |
| 2288 | match := route.match("/user/keys/1337", "/user/keys/1337", &verifyParams) |
| 2289 | require.True(b, match) |
| 2290 | require.Equal(b, []string{"1337"}, verifyParams[0:len(parsed.params)]) |
| 2291 | } |
| 2292 | |
| 2293 | func Benchmark_Route_Match_Star_Parallel(b *testing.B) { |
| 2294 | var match bool |
nothing calls this directly
no test coverage detected