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

Function Benchmark_Ctx_Range

ctx_test.go:5334–5366  ·  view source on GitHub ↗

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

(b *testing.B)

Source from the content-addressed store, hash-verified

5332
5333// go test -v -run=^$ -bench=Benchmark_Ctx_Range -benchmem -count=4
5334func Benchmark_Ctx_Range(b *testing.B) {
5335 app := New()
5336 c := app.AcquireCtx(&fasthttp.RequestCtx{})
5337 defer app.ReleaseCtx(c)
5338
5339 testCases := []struct {
5340 str string
5341 start int64
5342 end int64
5343 }{
5344 {str: "bytes=-700", start: 300, end: 999},
5345 {str: "bytes=500-", start: 500, end: 999},
5346 {str: "bytes=500-1000", start: 500, end: 999},
5347 {str: "bytes=0-700,800-1000", start: 0, end: 700},
5348 }
5349
5350 for _, tc := range testCases {
5351 b.Run(tc.str, func(b *testing.B) {
5352 c.Request().Header.Set(HeaderRange, tc.str)
5353 var (
5354 result Range
5355 err error
5356 )
5357 for b.Loop() {
5358 result, err = c.Range(1000)
5359 }
5360 require.NoError(b, err)
5361 require.Equal(b, "bytes", result.Type)
5362 require.Equal(b, tc.start, result.Ranges[0].Start)
5363 require.Equal(b, tc.end, result.Ranges[0].End)
5364 })
5365 }
5366}
5367
5368// go test -run Test_Ctx_Route
5369func Test_Ctx_Route(t *testing.T) {

Callers

nothing calls this directly

Calls 6

AcquireCtxMethod · 0.80
ReleaseCtxMethod · 0.80
NewFunction · 0.70
SetMethod · 0.65
RequestMethod · 0.65
RangeMethod · 0.65

Tested by

no test coverage detected