1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 13:47:31 +02:00

Debug time display improvements.

This commit is contained in:
Cameron
2017-01-21 09:31:13 -08:00
parent f6925ee4e7
commit 15c586b5dc

View File

@@ -352,7 +352,8 @@ class e107_db_debug {
} }
function Show_Performance() { function Show_Performance()
{
// //
// Stats by Time Marker // Stats by Time Marker
// //
@@ -362,28 +363,37 @@ class e107_db_debug {
$this->Mark_Time('Stop'); $this->Mark_Time('Stop');
if (!E107_DBG_TIMEDETAILS) return ''; if(!E107_DBG_TIMEDETAILS)
{
return '';
}
$totTime = e107::getSingleton('e107_traffic')->TimeDelta($eTimingStart, $eTimingStop); $totTime = e107::getSingleton('e107_traffic')->TimeDelta($eTimingStart, $eTimingStop);
$text = "\n<table class='fborder table table-striped table-condensed'>\n"; $text = "\n<table class='fborder table table-striped table-condensed'>\n";
$bRowHeaders=FALSE; $bRowHeaders = false;
reset($this->aTimeMarks); reset($this->aTimeMarks);
$aSum = $this->aTimeMarks[0]; // create a template from the 'real' array $aSum = $this->aTimeMarks[0]; // create a template from the 'real' array
$aSum['Index'] = ''; $aSum['Index'] = '';
$aSum['What'] = 'Total'; $aSum['What'] = 'Total';
$aSum['Time'] = 0; $aSum['Time'] = 0;
$aSum['DB Time'] = 0; $aSum['DB Time'] = 0;
$aSum['DB Count'] = 0; $aSum['DB Count'] = 0;
$aSum['Memory']=''; $aSum['Memory'] = 0;
while (list($tKey, $tMarker) = each($this->aTimeMarks)) { while(list($tKey, $tMarker) = each($this->aTimeMarks))
if (!$bRowHeaders) { {
if(!$bRowHeaders)
{
// First time: emit headers // First time: emit headers
$bRowHeaders=TRUE; $bRowHeaders = true;
$text .= "<tr><td class='fcaption' style='text-align:right'><b>" . implode("</b>&nbsp;</td><td class='fcaption' style='text-align:right'><b>", array_keys($tMarker)) . "</b>&nbsp;</td><td class='fcaption' style='text-align:right'><b>OB Lev&nbsp;</b></td></tr>\n"; $text .= "<tr><td class='fcaption' style='text-align:right'><b>" . implode("</b>&nbsp;</td><td class='fcaption' style='text-align:right'><b>", array_keys($tMarker)) . "</b>&nbsp;</td><td class='fcaption' style='text-align:right'><b>OB Lev&nbsp;</b></td></tr>\n";
$aUnits = $tMarker; $aUnits = $tMarker;
foreach ($aUnits as $key=>$val) { foreach($aUnits as $key => $val)
switch ($key) { {
switch($key)
{
case 'DB Time': case 'DB Time':
case 'Time': case 'Time':
$aUnits[$key] = '(msec)'; $aUnits[$key] = '(msec)';
@@ -398,9 +408,27 @@ class e107_db_debug {
$text .= "<tr><td class='fcaption' style='text-align:right'><b>" . implode("</b>&nbsp;</td><td class='fcaption' style='text-align:right'><b>", $aUnits) . "</b>&nbsp;</td></tr>\n"; $text .= "<tr><td class='fcaption' style='text-align:right'><b>" . implode("</b>&nbsp;</td><td class='fcaption' style='text-align:right'><b>", $aUnits) . "</b>&nbsp;</td></tr>\n";
} }
$tMem = $tMarker['Memory'];
$tMem = ($tMarker['Memory'] - $aSum['Memory']);
if($tMem < 0) // Quick Fix for negative numbers.
{
$tMem = 0.0000000001;
}
$tMarker['Memory'] = ($tMem ? number_format($tMem / 1024.0, 1) : '?'); // display if known $tMarker['Memory'] = ($tMem ? number_format($tMem / 1024.0, 1) : '?'); // display if known
if ($tMarker['What'] == 'Stop') {
if($tMem > 400000) // Highlight high memory usage.
{
$tMarker['Memory'] = "<span class='label label-danger'>".$tMarker['Memory']."</span>";
}
$aSum['Memory'] += $tMem;
if($tMarker['What'] == 'Stop')
{
$tMarker['Time'] = '&nbsp;'; $tMarker['Time'] = '&nbsp;';
$tMarker['%Time'] = '&nbsp;'; $tMarker['%Time'] = '&nbsp;';
$tMarker['%DB Count'] = '&nbsp;'; $tMarker['%DB Count'] = '&nbsp;';
@@ -408,7 +436,9 @@ class e107_db_debug {
$tMarker['DB Time'] = '&nbsp;'; $tMarker['DB Time'] = '&nbsp;';
$tMarker['OB Lev'] = $this->aOBMarks[$tKey]; $tMarker['OB Lev'] = $this->aOBMarks[$tKey];
$tMarker['DB Count'] = '&nbsp;'; $tMarker['DB Count'] = '&nbsp;';
} else { }
else
{
// Convert from start time to delta time, i.e. from now to next entry // Convert from start time to delta time, i.e. from now to next entry
$nextMarker = current($this->aTimeMarks); $nextMarker = current($this->aTimeMarks);
$aNextT = $nextMarker['Time']; $aNextT = $nextMarker['Time'];
@@ -429,11 +459,16 @@ class e107_db_debug {
$text .= "<tr><td class='forumheader3' >" . implode("&nbsp;</td><td class='forumheader3' style='text-align:right'>", array_values($tMarker)) . "&nbsp;</td></tr>\n"; $text .= "<tr><td class='forumheader3' >" . implode("&nbsp;</td><td class='forumheader3' style='text-align:right'>", array_values($tMarker)) . "&nbsp;</td></tr>\n";
if (isset($this->aMarkNotes[$tKey])) { if(isset($this->aMarkNotes[$tKey]))
{
$text .= "<tr><td class='forumheader3' >&nbsp;</td><td class='forumheader3' colspan='4'>"; $text .= "<tr><td class='forumheader3' >&nbsp;</td><td class='forumheader3' colspan='4'>";
$text .= $this->aMarkNotes[$tKey] . "</td></tr>\n"; $text .= $this->aMarkNotes[$tKey] . "</td></tr>\n";
} }
if ($tMarker['What'] == 'Stop') break;
if($tMarker['What'] == 'Stop')
{
break;
}
} }
$aSum['%Time'] = $totTime ? number_format(100.0 * ($aSum['Time'] / $totTime), 0) : 0; $aSum['%Time'] = $totTime ? number_format(100.0 * ($aSum['Time'] / $totTime), 0) : 0;
@@ -449,10 +484,10 @@ class e107_db_debug {
<td class='fcaption' style='text-align:right'><b>" . $aSum['%Time'] . "</b></td> <td class='fcaption' style='text-align:right'><b>" . $aSum['%Time'] . "</b></td>
<td class='fcaption' style='text-align:right'><b>" . $aSum['%DB Time'] . "</b></td> <td class='fcaption' style='text-align:right'><b>" . $aSum['%DB Time'] . "</b></td>
<td class='fcaption' style='text-align:right'><b>" . $aSum['%DB Count'] . "</b></td> <td class='fcaption' style='text-align:right'><b>" . $aSum['%DB Count'] . "</b></td>
<td class='fcaption' style='text-align:right'><b>".$aSum['Time']."</b></td> <td class='fcaption' style='text-align:right' title='Time (msec)'><b>" . $aSum['Time'] . "</b></td>
<td class='fcaption' style='text-align:right'><b>".$aSum['DB Time']."</b></td> <td class='fcaption' style='text-align:right' title='DB Time (msec)'><b>" . $aSum['DB Time'] . "</b></td>
<td class='fcaption' style='text-align:right'><b>" . $aSum['DB Count'] . "</b></td> <td class='fcaption' style='text-align:right'><b>" . $aSum['DB Count'] . "</b></td>
<td class='fcaption' style='text-align:right'><b>".$tMarker['Memory']."</b></td> <td class='fcaption' style='text-align:right' title='Memory (Kb)'><b>" . number_format($aSum['Memory'] / 1024, 1) . "</b></td>
<td class='fcaption' style='text-align:right'><b>" . $tMarker['OB Lev'] . "</b></td> <td class='fcaption' style='text-align:right'><b>" . $tMarker['OB Lev'] . "</b></td>
</tr> </tr>
@@ -470,7 +505,7 @@ class e107_db_debug {
$text .= "\n<table class='fborder table table-striped table-condensed'>\n"; $text .= "\n<table class='fborder table table-striped table-condensed'>\n";
$bRowHeaders=FALSE; $bRowHeaders = false;
$aSum = $this->aDBbyTable['core']; // create a template from the 'real' array $aSum = $this->aDBbyTable['core']; // create a template from the 'real' array
$aSum['Table'] = 'Total'; $aSum['Table'] = 'Total';
$aSum['%DB Count'] = 0; $aSum['%DB Count'] = 0;
@@ -478,13 +513,17 @@ class e107_db_debug {
$aSum['DB Time'] = 0; $aSum['DB Time'] = 0;
$aSum['DB Count'] = 0; $aSum['DB Count'] = 0;
foreach ($this->aDBbyTable as $curTable) { foreach($this->aDBbyTable as $curTable)
if (!$bRowHeaders) { {
$bRowHeaders=TRUE; if(!$bRowHeaders)
{
$bRowHeaders = true;
$text .= "<tr><td class='fcaption'><b>" . implode("</b></td><td class='fcaption'><b>", array_keys($curTable)) . "</b></td></tr>\n"; $text .= "<tr><td class='fcaption'><b>" . implode("</b></td><td class='fcaption'><b>", array_keys($curTable)) . "</b></td></tr>\n";
$aUnits = $curTable; $aUnits = $curTable;
foreach ($aUnits as $key=>$val) { foreach($aUnits as $key => $val)
switch ($key) { {
switch($key)
{
case 'DB Time': case 'DB Time':
$aUnits[$key] = '(msec)'; $aUnits[$key] = '(msec)';
break; break;