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

Function Benchmark_Router_GitHub_API

router_test.go:1890–1916  ·  view source on GitHub ↗

go test -run=^$ -bench=Benchmark_Router_GitHub_API -benchmem -count=16

(b *testing.B)

Source from the content-addressed store, hash-verified

1888
1889// go test -run=^$ -bench=Benchmark_Router_GitHub_API -benchmem -count=16
1890func Benchmark_Router_GitHub_API(b *testing.B) {
1891 app := New()
1892 registerDummyRoutes(app)
1893 app.startupProcess()
1894
1895 c := &fasthttp.RequestCtx{}
1896 var match bool
1897 var err error
1898
1899 b.ResetTimer()
1900 for i := range routesFixture.TestRoutes {
1901 b.RunParallel(func(pb *testing.PB) {
1902 c.Request.Header.SetMethod(routesFixture.TestRoutes[i].Method)
1903 for pb.Next() {
1904 c.URI().SetPath(routesFixture.TestRoutes[i].Path)
1905
1906 ctx := app.AcquireCtx(c).(*DefaultCtx) //nolint:errcheck,forcetypeassert // not needed
1907
1908 match, err = app.next(ctx)
1909 app.ReleaseCtx(ctx)
1910 }
1911 })
1912
1913 require.NoError(b, err)
1914 require.True(b, match)
1915 }
1916}
1917
1918type testRoute struct {
1919 Method string `json:"method"`

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected