(b *testing.B)
| 2374 | } |
| 2375 | |
| 2376 | func Benchmark_Router_GitHub_API_Parallel(b *testing.B) { |
| 2377 | app := New() |
| 2378 | registerDummyRoutes(app) |
| 2379 | app.startupProcess() |
| 2380 | b.ResetTimer() |
| 2381 | for i := range routesFixture.TestRoutes { |
| 2382 | b.RunParallel(func(pb *testing.PB) { |
| 2383 | // Each worker gets its own RequestCtx and local variables to avoid data races |
| 2384 | c := &fasthttp.RequestCtx{} |
| 2385 | c.Request.Header.SetMethod(routesFixture.TestRoutes[i].Method) |
| 2386 | for pb.Next() { |
| 2387 | c.URI().SetPath(routesFixture.TestRoutes[i].Path) |
| 2388 | ctx := acquireDefaultCtxForRouterBenchmark(b, app, c) |
| 2389 | //nolint:errcheck // Benchmark hot path - error checked in verification |
| 2390 | _, _ = app.next(ctx) |
| 2391 | app.ReleaseCtx(ctx) |
| 2392 | } |
| 2393 | }) |
| 2394 | |
| 2395 | // Single-threaded verification on a fresh context to preserve correctness checks |
| 2396 | verifyC := &fasthttp.RequestCtx{} |
| 2397 | verifyC.Request.Header.SetMethod(routesFixture.TestRoutes[i].Method) |
| 2398 | verifyC.URI().SetPath(routesFixture.TestRoutes[i].Path) |
| 2399 | verifyCtx := acquireDefaultCtxForRouterBenchmark(b, app, verifyC) |
| 2400 | match, err := app.next(verifyCtx) |
| 2401 | app.ReleaseCtx(verifyCtx) |
| 2402 | require.NoError(b, err) |
| 2403 | require.True(b, match) |
| 2404 | } |
| 2405 | } |
| 2406 | |
| 2407 | // go test -run Test_Route_URL |
| 2408 | func Test_Route_URL(t *testing.T) { |
nothing calls this directly
no test coverage detected