Added correct page render time in the default layout.

Added a function elapsedTime() that can be called anywhere to see how long the page has taken to render thus far.
query debugging shows current render time to help detect performance issues.
This commit is contained in:
Znote 2015-05-21 19:22:58 +02:00
parent 2a38590b96
commit 3036d61926
3 changed files with 13 additions and 9 deletions

View File

@ -271,7 +271,7 @@ function mysql_select_single($query) {
$aacQueries++; $aacQueries++;
global $accQueriesData; global $accQueriesData;
$accQueriesData[] = $query; $accQueriesData[] = "[" . elapsedTime() . "] " . $query;
$result = mysqli_query($connect,$query) or die(var_dump($query)."<br>(query - <font color='red'>SQL error</font>) <br>Type: <b>select_single</b> (select single row from database)<br><br>".mysqli_error($connect)); $result = mysqli_query($connect,$query) or die(var_dump($query)."<br>(query - <font color='red'>SQL error</font>) <br>Type: <b>select_single</b> (select single row from database)<br><br>".mysqli_error($connect));
$row = mysqli_fetch_assoc($result); $row = mysqli_fetch_assoc($result);
return !empty($row) ? $row : false; return !empty($row) ? $row : false;
@ -283,7 +283,7 @@ function mysql_select_multi($query){
global $aacQueries; global $aacQueries;
$aacQueries++; $aacQueries++;
global $accQueriesData; global $accQueriesData;
$accQueriesData[] = $query; $accQueriesData[] = "[" . elapsedTime() . "] " . $query;
$array = array(); $array = array();
$results = mysqli_query($connect,$query) or die(var_dump($query)."<br>(query - <font color='red'>SQL error</font>) <br>Type: <b>select_multi</b> (select multiple rows from database)<br><br>".mysqli_error($connect)); $results = mysqli_query($connect,$query) or die(var_dump($query)."<br>(query - <font color='red'>SQL error</font>) <br>Type: <b>select_multi</b> (select multiple rows from database)<br><br>".mysqli_error($connect));
while($row = mysqli_fetch_assoc($results)) { while($row = mysqli_fetch_assoc($results)) {
@ -307,7 +307,7 @@ function voidQuery($query) {
global $aacQueries; global $aacQueries;
$aacQueries++; $aacQueries++;
global $accQueriesData; global $accQueriesData;
$accQueriesData[] = $query; $accQueriesData[] = "[" . elapsedTime() . "] " . $query;
mysqli_query($connect,$query) or die(var_dump($query)."<br>(query - <font color='red'>SQL error</font>) <br>Type: <b>voidQuery</b> (voidQuery is used for update, insert or delete from database)<br><br>".mysqli_error($connect)); mysqli_query($connect,$query) or die(var_dump($query)."<br>(query - <font color='red'>SQL error</font>) <br>Type: <b>voidQuery</b> (voidQuery is used for update, insert or delete from database)<br><br>".mysqli_error($connect));
} }
?> ?>

View File

@ -5,6 +5,15 @@ $l_time = explode(' ', $l_time);
$l_time = $l_time[1] + $l_time[0]; $l_time = $l_time[1] + $l_time[0];
$l_start = $l_time; $l_start = $l_time;
function elapsedTime($l_start = false, $l_time = false) {
if ($l_start === false) global $l_start;
if ($l_time === false) global $l_time;
$l_time = explode(' ', microtime());
$l_finish = $l_time[1] + $l_time[0];
return round(($l_finish - $l_start), 4);
}
$time = time(); $time = time();
$version = '1.5_SVN'; $version = '1.5_SVN';

View File

@ -4,12 +4,7 @@
<footer> <footer>
<p>&copy; <?php echo $config['site_title'];?>. <p>&copy; <?php echo $config['site_title'];?>.
<?php <?php
$time = microtime(); echo 'Server date and clock is: '. getClock(false, true) .' Page generated in '. elapsedTime() .' seconds. Q: '.$aacQueries;
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo 'Server date and clock is: '. getClock(false, true) .' Page generated in '. $total_time .' seconds. Q: '.$aacQueries;
?> ?>
<a href="http://www.css3templates.co.uk">Design: css3templates.co.uk</a>. Engine: <a href="credits.php">Znote AAC</a></p> <a href="http://www.css3templates.co.uk">Design: css3templates.co.uk</a>. Engine: <a href="credits.php">Znote AAC</a></p>
</footer> </footer>