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

Function Benchmark_Router_GitHub_API_Parallel

router_test.go:2376–2405  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

2374}
2375
2376func 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
2408func Test_Route_URL(t *testing.T) {

Callers

nothing calls this directly

Calls 10

registerDummyRoutesFunction · 0.85
startupProcessMethod · 0.80
SetMethodMethod · 0.80
SetPathMethod · 0.80
URIMethod · 0.80
ReleaseCtxMethod · 0.80
NewFunction · 0.70
NextMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected