Take the 2-minute tour ×

We're updating our ancient internal PHP application at work. Right now, we gather extensive performance measurements on every pageview, and log them to the database. Additionally, users requested that some of the metrics be displayed at the bottom of the page. This worked out pretty well for us, because the last thing that the application does on every request is include the file containing the HTML footer. The footer code calls the function to log the performance metrics to the database, and returns them for inclusion in the output to the user.

The updated parts of the application use an MVC framework and a Dispatch/Request/Response loop. The page footer is no longer the last thing done. In fact, it could very well be the first thing done, before the rest of the page is created.

Because we can grab the Response before it's returned to the user, we could try to include placeholders for the performance metrics in the footer and simply replace them with the actual numbers, but this strikes me as a bad idea somehow.

How do you handle this in your modern web app? While we're using PHP, I'm curious how it's done in a Ruby/Rails app, and in your favorite Python framework.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

IN Zend Framework for PHP we have overloaded postDispatch() where we attach a partial that calls a helper that collects the final metrics (at least I believe this is how we do it). Another way is for us to overload the Zend Framework response object to append it after the render action.

RoR has the same ability (overloading every step of the render) and I'm sure most MVC frameworks will as well. As a note I remember CodIgniter had automatic debug information when in development mode, it should be a simple case of finding where that is rendered and simulating it.

Good luck.

share|improve this answer
I'll have to look at CodeIgniter's way of doing it. Our "framework" is home-grown and is maybe a few dozen lines in total right now. –  Charles May 29 '10 at 17:10
add comment

Your Answer


