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

Function Benchmark_Communication_Flow_Parallel

app_test.go:3314–3340  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

3312}
3313
3314func 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
3343func Benchmark_Ctx_AcquireReleaseFlow(b *testing.B) {

Callers

nothing calls this directly

Calls 8

HandlerMethod · 0.80
SetMethodMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
SendStringMethod · 0.65
NextMethod · 0.65
BodyMethod · 0.65
StatusCodeMethod · 0.45

Tested by

no test coverage detected