MCPcopy Index your code
hub / github.com/labstack/echo / benchmarkRouterRoutes

Function benchmarkRouterRoutes

router_test.go:2884–2918  ·  view source on GitHub ↗
(b *testing.B, routes []testRoute, routesToFind []testRoute)

Source from the content-addressed store, hash-verified

2882}
2883
2884func benchmarkRouterRoutes(b *testing.B, routes []testRoute, routesToFind []testRoute) {
2885 e := New()
2886 r := e.router
2887 req := httptest.NewRequest(http.MethodGet, "/", nil)
2888 b.ReportAllocs()
2889
2890 // Add routes
2891 for _, route := range routes {
2892 e.AddRoute(Route{
2893 Method: route.Method,
2894 Path: route.Path,
2895 Handler: func(c *Context) error {
2896 return nil
2897 },
2898 })
2899 }
2900
2901 // Routes adding are performed just once, so it doesn't make sense to see that in the benchmark
2902 b.ResetTimer()
2903
2904 // Find routes
2905 for i := 0; i < b.N; i++ {
2906 for _, route := range routesToFind {
2907 c := e.contextPool.Get().(*Context)
2908 c.request = req
2909
2910 req.Method = route.Method
2911 req.URL.Path = route.Path
2912
2913 _ = r.Route(c)
2914
2915 e.contextPool.Put(c)
2916 }
2917 }
2918}
2919
2920func TestDefaultRouter_Remove(t *testing.T) {
2921 var testCases = []struct {

Calls 4

NewFunction · 0.85
RouteMethod · 0.65
AddRouteMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…