As of this PR, Symfony is way faster than FastRoute when using a compiled version of the UrlMatcher. As a reminder, compiling the UrlMatcher is the default and recommended way of using the Symfony Routing component, because it gives a true performance boost in both loading routes (because matcher is compiled and you don't have to recreate the entire route collection) and matching them (because the compiled UrlMatcher is optimized for runtime).
I suggest to make another benchmark with Symfony Routing instead of FastRoute, and use a compiled version of the UrlMatcher 🙂
Thanks for commenting. I will test. Two days ago I made a change to the route system that greatly increased performance github.com/inphinit/teeny/blob/mas..., using $slice = array_slice($this->paramRoutes, $indexRoutes, $limit); to get 20 "regex routes" and testing them at the same time (using a single preg_match), all combined with the (?J) to allow groups with the same name and then separate the "callbacks" from those routes and set group names to identify the routes to lessen the work on the "PHP side"
Before (version 0.2.6): 1566.68 requests per sec
Before (version 0.2.6): Time per request 6.383ms
After (version 0.2.7 and 0.2.8): 3995.64 requests per sec
After (version 0.2.7 and 0.2.8): Time per request 2.503ms
I still promise that I will test the "Symfony Routing component". Thanks!
As of this PR, Symfony is way faster than FastRoute when using a compiled version of the UrlMatcher. As a reminder, compiling the UrlMatcher is the default and recommended way of using the Symfony Routing component, because it gives a true performance boost in both loading routes (because matcher is compiled and you don't have to recreate the entire route collection) and matching them (because the compiled UrlMatcher is optimized for runtime).
I suggest to make another benchmark with Symfony Routing instead of FastRoute, and use a compiled version of the UrlMatcher 🙂
Thanks for commenting. I will test. Two days ago I made a change to the route system that greatly increased performance github.com/inphinit/teeny/blob/mas..., using
$slice = array_slice($this->paramRoutes, $indexRoutes, $limit);
to get 20 "regex routes" and testing them at the same time (using a singlepreg_match
), all combined with the(?J)
to allow groups with the same name and then separate the "callbacks" from those routes and set group names to identify the routes to lessen the work on the "PHP side"I still promise that I will test the "Symfony Routing component". Thanks!
Thanks for pointing it out, Alex. Symfony's compiler is pretty interesting. It compiles all dynamic routes into a regex that resembles a trie.
gist.github.com/hbgl/cfa637dcd9aa3...
To be fair, FastRoute also has another dispatcher implementation that uses an almost identical algorithm.