(b *testing.B)
| 3312 | } |
| 3313 | |
| 3314 | func Benchmark_Communication_Flow_Parallel(b *testing.B) { |
| 3315 | app := New() |
| 3316 | |
| 3317 | app.Get("/", func(c Ctx) error { |
| 3318 | return c.SendString("Hello, World!") |
| 3319 | }) |
| 3320 | |
| 3321 | h := app.Handler() |
| 3322 | |
| 3323 | b.ReportAllocs() |
| 3324 | b.RunParallel(func(pb *testing.PB) { |
| 3325 | fctx := &fasthttp.RequestCtx{} |
| 3326 | fctx.Request.Header.SetMethod(MethodGet) |
| 3327 | fctx.Request.SetRequestURI("/") |
| 3328 | for pb.Next() { |
| 3329 | h(fctx) |
| 3330 | } |
| 3331 | }) |
| 3332 | |
| 3333 | verifyCtx := &fasthttp.RequestCtx{} |
| 3334 | verifyCtx.Request.Header.SetMethod(MethodGet) |
| 3335 | verifyCtx.Request.SetRequestURI("/") |
| 3336 | h(verifyCtx) |
| 3337 | |
| 3338 | require.Equal(b, 200, verifyCtx.Response.Header.StatusCode()) |
| 3339 | require.Equal(b, "Hello, World!", string(verifyCtx.Response.Body())) |
| 3340 | } |
| 3341 | |
| 3342 | // go test -v -run=^$ -bench=Benchmark_Ctx_AcquireReleaseFlow -benchmem -count=4 |
| 3343 | func Benchmark_Ctx_AcquireReleaseFlow(b *testing.B) { |
nothing calls this directly
no test coverage detected