There's a few targeted enhancements we should make here:
ApiControllerActionSelector.cs@311 - GetCombinedParameterNames should move inside IF
HttpParsedRoute.cs@503 HttpRouteParser.SplitUriToPathSegments is called once for each route
It would be nice to clean this up - but it's a public API change so we likely can't
HttpRoute.cs@116 request path is sanitized/built for each route
Some comparison tests for scenarios involving different numbers of controllers using different routing techniques. In all cases, which type of route was eventually matched did not have much impact on the results.
The numbers provided here are based on throughput for a webapi application hosted in IIS. The controller actions themselves are trival as this is intended to measure overhead of routing. Each controller has 5 actions with differing http actions and parameter counts - the focus of this test is on the general overhead of each routing technique - the diversity of actions is present to simulate a typical usage pattern.
Traditional Actions Attribute Routed Actions Throughput
5 5 2417
5 500 2440
500 5 2398
5 5000 928
5000 5 2423
While there's no real trend at low numbers of actions, a very large number of attribute routed actions doubles the overhead of routing, while a large number of traditional routed actions has virtually no impact. This could be concerning if we begin to advertise attribute routing as our recommended versioning technique.
ApiControllerActionSelector.cs@311 - GetCombinedParameterNames should move inside IF
HttpParsedRoute.cs@503 HttpRouteParser.SplitUriToPathSegments is called once for each route
It would be nice to clean this up - but it's a public API change so we likely can't
HttpRoute.cs@116 request path is sanitized/built for each route
Some comparison tests for scenarios involving different numbers of controllers using different routing techniques. In all cases, which type of route was eventually matched did not have much impact on the results.
The numbers provided here are based on throughput for a webapi application hosted in IIS. The controller actions themselves are trival as this is intended to measure overhead of routing. Each controller has 5 actions with differing http actions and parameter counts - the focus of this test is on the general overhead of each routing technique - the diversity of actions is present to simulate a typical usage pattern.
Traditional Actions Attribute Routed Actions Throughput
5 5 2417
5 500 2440
500 5 2398
5 5000 928
5000 5 2423
While there's no real trend at low numbers of actions, a very large number of attribute routed actions doubles the overhead of routing, while a large number of traditional routed actions has virtually no impact. This could be concerning if we begin to advertise attribute routing as our recommended versioning technique.