| 1 |
/*
|
| 2 |
* This PHP-type blocks displays the number of queries against the
|
| 3 |
* the database and the total clock time required for these queries
|
| 4 |
* used in the generation of this page. The time does not include
|
| 5 |
* any other time spent in PHP code, only during SQL queries.
|
| 6 |
*
|
| 7 |
* Optionally, if the 2 commented out lines are commented in, it will
|
| 8 |
* list all of the queries and how much time they each took.
|
| 9 |
*
|
| 10 |
* Note that the capturing of database query times is OFF by default
|
| 11 |
* in Drupal. It must be turned ON by setting the "dev_query" variable
|
| 12 |
* in the "variable" table. That can be done by hand via this SQL:
|
| 13 |
* Insert Into variable Values ("dev_query", 's:1:"1";');
|
| 14 |
*
|
| 15 |
* $Id$
|
| 16 |
* Author: Chris Johnson / chris@chaska.com
|
| 17 |
*/
|
| 18 |
|
| 19 |
global $queries;
|
| 20 |
$sum = 0.0;
|
| 21 |
foreach ($queries as $query) {
|
| 22 |
$sum += $query[1];
|
| 23 |
}
|
| 24 |
$sum = sprintf("%2.5f", $sum);
|
| 25 |
$output .= "Page generated with ".count($queries)." queries which consumed $sum seconds";
|
| 26 |
// Comment in the following 2 lines to get full list of queries and their
|
| 27 |
// times. Note it could be 50 or 70 queries long for an average node page!
|
| 28 |
// $header = array("Query", "Time");
|
| 29 |
// $output .= table($header, $queries);
|
| 30 |
return $output;
|