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

Function Benchmark_Ctx_Append

ctx_test.go:730–741  ·  view source on GitHub ↗

go test -v -run=^$ -bench=Benchmark_Ctx_Append -benchmem -count=4

(b *testing.B)

Source from the content-addressed store, hash-verified

728
729// go test -v -run=^$ -bench=Benchmark_Ctx_Append -benchmem -count=4
730func Benchmark_Ctx_Append(b *testing.B) {
731 app := New()
732 c := app.AcquireCtx(&fasthttp.RequestCtx{}).(*DefaultCtx) //nolint:errcheck,forcetypeassert // not needed
733
734 b.ReportAllocs()
735 for b.Loop() {
736 c.Append("X-Custom-Header", "Hello")
737 c.Append("X-Custom-Header", "World")
738 c.Append("X-Custom-Header", "Hello")
739 }
740 require.Equal(b, "Hello, World", app.toString(c.Response().Header.Peek("X-Custom-Header")))
741}
742
743// go test -run Test_Ctx_Attachment
744func Test_Ctx_Attachment(t *testing.T) {

Callers

nothing calls this directly

Calls 5

AcquireCtxMethod · 0.80
toStringMethod · 0.80
NewFunction · 0.70
AppendMethod · 0.65
ResponseMethod · 0.65

Tested by

no test coverage detected