On Thu, Oct 7, 2010 at 5:58 AM, Christian Heinrich <[email protected]> wrote: > On Thu, Oct 7, 2010 at 5:03 AM, Andrei Iarus <[email protected]> wrote: >> Hello, >> I would like to find a nice solution to get the time, in which a page is >> generated in ZF. >> Problems: If I do it in public/index.php, I can't display it in the HTML >> (except with an "echo' call, but this will make the HTML invalid (as the >> </html> tag is already displayed) ). >> Other ideas? >> Thank you. >> >> >> > Hi Andrei, > > I would write a FrontController Plugin and hook into the right extension > points. If you want to have routing time counted, then hook into > routingStart() etc. methods. (Not sure whether its actually called > routingStart, but you'll find the right hooks within > Zend_Controller_Front::dispatch().) > > The last one might be in the dispatchShutdown() method. > > Best regards > Christian
On a recent project, I defined a constant at the top of public/index.php that is set to microtime(true), and then output the elapsed time (in this case using a Zend_Log instance rather than to the screen) in an action helper postDispatch() method. It is not a 100% solution, as there is still work done after the dispatch loop finishes (the dispatchShutdown() method you mentioned would be a little better), but it captures enough to get a good idea how long requests are taking to execute. Andrew
