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++;
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));
$row = mysqli_fetch_assoc($result);
return !empty($row) ? $row : false;
@@ -283,7 +283,7 @@ function mysql_select_multi($query){
global $aacQueries;
$aacQueries++;
global $accQueriesData;
$accQueriesData[] = $query;
$accQueriesData[] = "[" . elapsedTime() . "] " . $query;
$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));
while($row = mysqli_fetch_assoc($results)) {
@@ -307,7 +307,7 @@ function voidQuery($query) {
global $aacQueries;
$aacQueries++;
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));
}
?>

View File

@@ -5,6 +5,15 @@ $l_time = explode(' ', $l_time);
$l_time = $l_time[1] + $l_time[0];
$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();
$version = '1.5_SVN';