4 ms·
Explain here: - Pux uses simpler data structure (indexed array) to store the patterns and flags. (In PHP internals, zend_hash_index_find is faster than zend_ha
by pedro93 13y ago
Explain here:
- Pux uses simpler data structure (indexed array) to store the patterns and flags. (In PHP internals, zend_hash_index_find is faster than zend_hash_find).
- When matching routes, symfony uses a lot of function calls for each route:
https://github.com/symfony/Routing/blob/master/Matcher/UrlMatcher.php#L124 https://github.com/symfony/Routing/blob/master/Matcher/UrlMa...
- Pux fetches the pattern from an indexed-array:
https://github.com/c9s/Pux/blob/master/src/Pux/Mux.php#L189 https://github.com/c9s/Pux/blob/master/src/Pux/Mux.php#L189
- Pux separates static routes and dynamic routes automatically, Pux uses hash table to look up static routes without looping the whole route array.
- Pux\Mux is written in C extension, method calls are faster!
- With C extension, there is no class loading overhead.
- Pux compiles routes to plain PHP array, the compiled routes can be loaded very fast. you don't need to call functions to register your routes before using it.
- fooyc 13y agoThanks for your answer. > When matching routes, symfony uses a lot of function calls for each route This is the slow UrlMatcher. The one used by default in the standard symfony edition generates code like this: https://github.com/symfony/Routing/blob/0ee25e6580bd4169c1289bdcbefa22220a3a4a8f/Tests/Fixtures/dumper/url_matcher1.php#L23 https://github.com/symfony/Routing/blob/0ee25e6580bd4169c128... , and this code is used for matching instead.