diff --git a/manual/new/docs/en/plugins.txt b/manual/new/docs/en/plugins.txt index 9835bd595..ee7f148c2 100644 --- a/manual/new/docs/en/plugins.txt +++ b/manual/new/docs/en/plugins.txt @@ -1,43 +1,6 @@ ++ Validators ++ View ++ Profiler -+++ Introduction - -{{Doctrine_Connection_Profiler}} is an eventlistener 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 eventlistener for {{Doctrine_Connection}}. - - -$conn = Doctrine_Manager::connection($dsn); - -$profiler = new Doctrine_Connection_Profiler(); - -$conn->setListener($profiler); - -+++ Basic usage - -Perhaps some of your pages is loading slowly. The following shows how to build a complete profiler report from the connection: - - -$totalTime = $profiler->getTotalElapsedSecs(); -$queryCount = $profiler->getTotalNumQueries(); -$longestTime = 0; -$longestQuery = null; - -foreach ($profiler->getQueryProfiles() as $query) { - if ($query->getElapsedSecs() > $longestTime) { - $longestTime = $query->getElapsedSecs(); - $longestQuery = $query->getQuery(); - } -} -echo 'Executed ' . $queryCount . ' queries in ' . $totalTime . ' seconds' . "\n"; -echo 'Average query length: ' . $totalTime / $queryCount . ' seconds' . "\n"; -echo 'Queries per second: ' . $queryCount / $totalTime . "\n"; -echo 'Longest query length: ' . $longestTime . "\n"; -echo 'Longest query: ' . $longestQuery . "\n"; - - -+++ Advanced usage ++ Locking Manager ++ Connection Profiler ++ AuditLog and versioning diff --git a/manual/new/docs/en/plugins/profiler.txt b/manual/new/docs/en/plugins/profiler.txt new file mode 100644 index 000000000..fa9c15b6b --- /dev/null +++ b/manual/new/docs/en/plugins/profiler.txt @@ -0,0 +1,32 @@ ++++ Introduction +{{Doctrine_Connection_Profiler}} is an eventlistener 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 eventlistener for {{Doctrine_Connection}}. + + +$conn = Doctrine_Manager::connection($dsn); + +$profiler = new Doctrine_Connection_Profiler(); + +$conn->setListener($profiler); + ++++ Basic usage + +Perhaps some of your pages is loading slowly. The following shows how to build a complete profiler report from the connection: + + +$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)){ + var_dump($params); + } +} +echo "Total time: " . $time . "
\n"; +
+ ++++ Advanced usage +