4 ms·
Routes are converted to regex and cached so this process does not need to happen every request. But, regex will again degrade performance.
by johnx123-up 15y ago
Routes are converted to regex and cached so this process
does not need to happen every request.
But, regex will again degrade performance.
- antihero 15y agoFor most requests, there is no regex matching done, because it also caches the resolved route for a given URI :)
- masklinn 15y agoFor matching? Because PCRE/PHP_PCRE already caches the compiled versions of regexes, so there's little to no perf hit there.
- 1880 15y agoAren't the regexes cached only for the current request anyway?
- Loic 15y agoFor Photon, a micro framework for Mongrel2, we use regex. Even with 100's or 1000's of routes, you cannot even see the cost of preg_match when benchmarking because the regex are organized in a tree following the URI structure like Django. It means that most of the time, a view is found within 2 to 3 preg_match calls. This - regex is slow to match anchored strings on a 120 character long URI - is a myth.