Doctrine_Connection_Profiler is an event listener for Doctrine_Connection. It provides flexible query profiling. Besides the SQL strings the query profiles include elapsed time to run the queries. This allows inspection of the queries that have been performed without the need for adding extra debugging code to model classes.
Doctrine_Connection_Profiler can be enabled by adding it as an event listener for Doctrine_Connection.
// test.php
// ...
$profiler = new Doctrine_Connection_Profiler();
$conn = Doctrine_Manager::connection();
$conn->setListener($profiler);
Perhaps some of your pages is loading slowly. The following shows how to build a complete profiler report from the connection:
// test.php
// ...
$time = 0;
foreach ($profiler as $event) {
$time += $event->getElapsedSecs();
echo $event->getName() . " " . sprintf("%f", $event->getElapsedSecs()) . "\n";
echo $event->getQuery() . "\n";
$params = $event->getParams();
if( ! empty($params)) {
print_r($params);
}
}
echo "Total time: " . $time . "\n";
Frameworks like symfony, Zend, etc. offer web debug toolbars that use this functionality provided by Doctrine for reporting the number of queries executed on every page as well as the time it takes for each query.