silexphp / Silex

[DEPRECATED -- Use Symfony instead] The PHP micro-framework based on the Symfony Components
https://silex.symfony.com
MIT License
3.58k stars 718 forks source link

Could it be that silex is a bit slow? #106

Closed palindrom-zz closed 13 years ago

palindrom-zz commented 13 years ago

Hi I tried to do some simple actions with silex (e.g. crud) but I think it is a bit slow. I use the simple /hello/{name} example and it needs about 1 sec until I see the response in the browser (measured in firebug). I mean only for displaying the name, one second is a long time. It shouldn't take longer than 250ms for such a simple action. Is this normal? Or is my apache not configured well?

igorw commented 13 years ago

You can use xdebug to profile your app. That will allow you to find the bottleneck. In firebug you can also see a breakdown of how long connection took, etc. But measuring this should really be done on the server.

palindrom-zz commented 13 years ago

The folling snippets needs one second for execution. There is only this request, no other ressources like images or css files.

require_once __DIR__.'/silex.phar';

$app = new Silex\Application();

$app->get('/hello/{name}', function ($name) {
    return "Hello $name";
});

$app->run();

Any suggestions why takes one second? I've got a simple ZF application where the whole dispatching needs one second too. So I think thats not normal. @igorw how long takes the upper request on your machine? less than 50ms?

igorw commented 13 years ago

It takes ~35ms here.

palindrom-zz commented 13 years ago

I made a profiling. I'm not very experienced reading the cachegrind data. http://www.fileserve.com/file/24qbByw But if I am reading correct there is a comulated time of 46ms. But why do I have 1sec in firebug when requesting the script? Is there something between browser and localhost? Which slows that down which i forgot?

palindrom-zz commented 13 years ago

I analyzed with firebug and it seemed that my dns lookup took so long. It was a Windows 7 problem! http://cubicspot.blogspot.com/2010/07/fixing-slow-apache-on-localhost-under.html I removed the semicolon of the localhost entry in the windows hosts file and now silex is fast. Strangely other simple non-framework php scripts were fast than ever.

igorw commented 13 years ago

In that case this issue can be closed.