aspnetcore/benchmarks/Microsoft.AspNetCore.Routin...
Ryan Nowak 147c9527f3
Implement EndpointSelector and MatcherPolicy (#646)
Implement EndpointSelector and MatcherPolicy

This change makes the EndpointSelector API more concrete, and is the
beggining of removing EndpointConstraint by making it obsolete.

To that end, I'm introducing MatcherPolicy, which is a
feature-collection API for registering policies that interact with the
DfaMatcher. The two policies that we'll need to start are:
- ability to order endpoints
- ability to append 'policy' nodes to the graph

These two concepts together replace EndpointConstraint. Extending our
graph representation is a really efficient way to processing most common
scenarios.

---

In general this helps with common cases where 4 or so endpoints match
the URL, but with different HTTP methods supported on each. Today we
have to process route values and call into some 'policy' to make a
decision about which one is the winner. This change pushes this
knowledge down into the graph so that it's roughly as cheap as a
dictionary lookup, and can be done allocation-free.

The big savings here is ability to remove more candidates *before*
collecting route data.

---

Along with this change, I also built 'rejection' into the DFA node
model, you can see an example with the HTTP Method handling that I
implemented. I implemented a policy that can treat failure to resolve an
HTTP method as a 405 response by returning a failure endpoint. This is
at the heart of much of the feedback we've gotten in this area around
versioning and http method handling. We also have a version of this
feature in MVC for [Consumes].
2018-07-24 17:31:51 -07:00
..
Matchers Implement EndpointSelector and MatcherPolicy (#646) 2018-07-24 17:31:51 -07:00
Properties
Microsoft.AspNetCore.Routing.Performance.csproj
RouteValueDictionaryBenchmark.cs
readme.md

readme.md

Compile the solution in Release mode (so binaries are available in release)

To run a specific benchmark add it as parameter.

dotnet run -c Release --framework <tfm> <benchmark_name>

To run all benchmarks use '*' as the name.

dotnet run -c Release --framework <tfm> *

If you run without any parameters, you'll be offered the list of all benchmarks and get to choose.

dotnet run -c Release --framework <tfm>