Fastest routing is: http://domain.com/filename.php?args
Pux – High Performance Router for PHP
51–58 of 58 posts
Re: Pux – High Performance Router for PHP
#52Earlier quoted context omitted.
Look at the php.net website source code. Another example could be the Wordpress source code. It's not handsome code, but it just works. Things like fat (either slim) frameworks should be memory resident (java or similar), not reloaded from scratch at each web request, it just won't never perform on big sites. Alternatively, if you need to deal with bigger applications, or massive traffic, you can build some kind of b…
Any "big site" will use an opcode cacher like XCache or APC to avoid reloading .php files from disk on every request.
Re: Pux – High Performance Router for PHP
#53Not sure the performance difference, but highly recommend Flight ( http://flightphp.com/ ) as a simple router. Flight is well suited especially for building APIs. Flight has great http helper methods as well (header, json response, etc). As far as performance, I seriously doubt the bottleneck in modern applications is the router.
have checked the code, there are a lot of magic method calls in flightphp. magic method calls are even slower than normal method call.
Re: Pux – High Performance Router for PHP
#54If they would only first explain what the heck is "routing in PHP"... Coming from the network programming side of things, "High Performance PHP Router" sounds like a spectacular oxymoron at best :)
Re: Pux – High Performance Router for PHP
#55> Pux tries not to consume computation time to build all routes dynamically (like Symfony/Routing). Instead, Pux compiles your routes to plain PHP array for caching, the compiled routes can be loaded from cache very fast. symfony/routing compiles routes only once to PHP code ([1]), and then that generated code is used for matching all subsequent requests. (There are multiple route matchers, but the default one works…
- 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/UrlMa...
- Pux fetches the pattern from an indexed-array:
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.
Re: Pux – High Performance Router for PHP
#56Earlier quoted context omitted.
Exactly. You don't need a 'router' when you have the filesystem and mod_rewrite.
What about when you are deploying with PHP-FPM or HipHopVM? A native routing component separates your application from your application server.
In over 10+ years of PHP development I have never needed a "native routing component". Call me crazy...
Re: Pux – High Performance Router for PHP
#57> Pux tries not to consume computation time to build all routes dynamically (like Symfony/Routing). Instead, Pux compiles your routes to plain PHP array for caching, the compiled routes can be loaded from cache very fast. symfony/routing compiles routes only once to PHP code ([1]), and then that generated code is used for matching all subsequent requests. (There are multiple route matchers, but the default one works…
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/UrlMa... - Pux fetches the pattern from an indexed-array: https://github.com/c9s/Pux/blob/master/src/Pux/Mux.php#L189 -…
> 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/0ee25e6580bd4169c128... , and this code is used for matching instead.
Re: Pux – High Performance Router for PHP
#58If the creators are watching, I think it'd be interesting to benchmark against the current Respect/Rest.
I thought the same thing. Here is a link for convenience. https://github.com/Respect/Rest