azjezz / benchmark-php-routing

Benchmark PHP Routing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add more scenarios

lcobucci opened this issue · comments

We introduced benchmarking on FastRoute some time ago (https://github.com/nikic/FastRoute/blob/master/benchmark/RealLifeExample.php) and have some scenarios which are missing here: invalid route and method not allowed.

I did observe that FastRoute was faster than SF for happy paths but not for NOT FOUND or METHOD NOT ALLOWED, maybe we get similar results for hacky-routing.

i assume hack-routing will be much slower with 405 due to some code i wrote back in 2019 hhvm/hack-router@cb83d40, and i didn't put much though in it, but it can be optimized.

however, optimizing this in hack-routing/hack-router would need a complete rewriting to the prefix map, so instead of having dict<Method, PrefixMap>, it would be PrefixMap<(Method, TResponder)>, which allows delgating the method matching to the end, but would also need to cache a list of all supported methods to allow early return for methods that we know are not supported.