On the example of the fastest frameworks "Phalcon" and "handmade".
We overtake Phalcon without compiling the source codes.

Why Phalcon? This is a fairly fresh and promising solution in terms of performance, although any framework can be in its place (this will become clear from the article).
')
For testing used phalcon 1.2.0beta1 64Bit for OpenSuse
Of the additional connected libraries PHP 5.3 was only php5-APC, for the purity of the experiment.
Guided by the manual create the application Phaclonindex.php
<?php try {
./app/controllers/IndexController.php
<?php class IndexController extends \Phalcon\Mvc\Controller { public function indexAction() { echo "<h1>Hello!</h1>"; } }
We start, works, memory_get_usage () says that 692kb of memory was used, an excellent result.
Apache Benchmark issues 8707 rps:

Amazing, awesome performance.
We look into the xdebug profile, optimism passes, and much becomes clear. What made this app so special? This is just echo. I have nothing against Phalcon, but what about more complex tasks?
Is it possible to make a PHP framework that will be faster than Phalcon without having to compile the source codes? Do not question, now do. And then we will also prove with tests that it is faster.
Create a competitor, call it Handmadeindex.php:
<?php require_once './Autoloader.php'; $autoloader = new Autoloader(array( 'paths'=>array( './app', './lib' ) )); $app = new Application(); $app->run();
Autoloader.php
The autoloader decided to take from his project, saved time.
The source code
here , nothing really tricked out, the usual PSR-0 compatible startup.
./lib/Application.php
<?php class Application { public function run() { $uri = $_SERVER['REQUEST_URI']; $paths = explode('/' , $uri); if(isset($paths[0]) && !empty($paths[0])){ $controller = ucfirst(strtolower($paths[0])).'_Controller'; }else{ $controller = 'Index_Controller'; } if(isset($paths[1]) && !empty($paths[1])){ $action = strtolower($paths[1]).'Action'; }else{ $action = 'indexAction'; } $controller = new $controller; $controller->$action(); } }
app / Index / Controller.php
<?php class IndexController extends Controller { public function indexAction() { echo "<h1>Hello!</h1>"; } }
We start, works, memory_get_usage () says that 624kb of memory are used. Excellent result!
Apache Benchmark issues 11793 rps:

Voila
11793 vs. 8707 rps, turned out to be not so difficult, 15 minutes of programming, without optimizations.
It remains to build beautiful graphics and put them closer to the title of the article.
Probably, there will be a question, why did I suddenly decide that, you can compare his favorite “insert name” framework with your self-made hack which has no special functionality at all. Look on the Internet, full of tests of platforms incomparable in purpose and functionality.
This is the essence of the topic, let's take a look at the payload of the two compared solutions. Open the profile that xdebug provides. For visualization I will use kcachegrind.
What we see:
Phalcon | Handmade |
---|

| 
|
Both solutions perform almost the same zero work.
Why all this.
As a developer, I often look at various solutions, the performance of the used platform plays an important role for me. But, unfortunately, having opened the regular framework, I can’t understand its real performance, the developers provide the Hello World test, which says absolutely nothing. It is difficult to navigate, it remains to find out the actual performance of a particular platform based on personal experience and understanding of what is obviously slowing down the system.
Such indicators as:
- a large amount of "magic"
- excessive abstraction and excessive functionality
- widespread use of the DI Container
- architecture based on the event model (not to be confused with Event-driven PHP )
You have to choose a balanced solution for convenience, functionality and performance. The last, in my opinion, the easiest place to optimize.
Morality
Do not pay attention to populist slogans and beautiful advertising, trends. Study as many solutions as possible, take the best from them, combine successful implementations. Do not write or read tests Hello World is a waste of time. Choose a tool sharpened to solve your specific problem.