Reputation: 3172
I have a symfony 1.4.x application and would like to be able to display the page load time.
In the dev environment, the load time is displayed in the debug toolbar.
How do I get that page load time in the app/%APP_NAME%/templates/layout.php?
Thanks
Upvotes: 1
Views: 1375
Reputation: 3280
In general to measure execution time in php you use something like that:
$start = microtime(true /*get as float*/);
//some code goes here (i.e. your symfony request dispatching)
$end = microtime(true);
echo sprintf("some code executed for %.3f seconds", $end - $start);
The trick with the Symfony framework will be to inject your code in good place, my proposals are:
Of course computing difference of page load time in layout file has it's drawbacks, because it does not calculate rendering time of entire page, just to the moment layout is rendered (which is acceptable, as rendering layout is one of last task of request dispatching, BUT layout is not always rendered)
To resolve this you could use your filter at the end of request to output javascript, which will append page load time to document (pretty much what symfony does with it's debug toolbar)
Upvotes: 1