From eaa44b075fb6500e92fb1989f6f91fe4841fd6a6 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 12 Dec 2020 11:38:31 -0800 Subject: [PATCH] Fix for displaying of debug mode: 'Time Analysis'. Additional markers added to class2.php. --- class2.php | 8 +++++--- e107_handlers/db_debug_class.php | 11 ++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/class2.php b/class2.php index 47fe62d28..ddf131324 100755 --- a/class2.php +++ b/class2.php @@ -1531,6 +1531,8 @@ if(!defined('THEME_LAYOUT')) } // Load library dependencies. +$dbg->logTime('Load Libraries'); +//$startTime = microtime(true); if(deftrue('e_ADMIN_AREA')) { e107::getTheme('current', true)->loadLibrary(); @@ -1539,9 +1541,8 @@ else { e107::getTheme('current')->loadLibrary(); } +//echo "\nRun Time: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n"; // ----------------------------------------------------------------------- - - if(!isset($_E107['no_menus'])) { $dbg->logTime('Init Menus'); @@ -1549,6 +1550,7 @@ if(!isset($_E107['no_menus'])) } // here we USE the theme +$dbg->logTime("Load admin_/theme.php file"); if(e_ADMIN_AREA) { $dbg->logTime('Loading Admin Theme'); @@ -1571,7 +1573,7 @@ else e107::scStyle($SC_WRAPPER); } } - +$dbg->logTime("Init Theme Class"); e107::getRender()->init(); // initialize theme class. //---------------------------- diff --git a/e107_handlers/db_debug_class.php b/e107_handlers/db_debug_class.php index 65082d193..5e5e6b58e 100644 --- a/e107_handlers/db_debug_class.php +++ b/e107_handlers/db_debug_class.php @@ -148,9 +148,13 @@ return null; } + + $timeNow = microtime(); $nMarks = ++$this->nTimeMarks; + // file_put_contents(e_LOG."debugClass.log",$nMarks."\t". $sMarker."\n", FILE_APPEND); + if(!strlen($sMarker)) { $sMarker = "Mark not set"; @@ -515,10 +519,11 @@ $obj = new ArrayObject($this->aTimeMarks); $it = $obj->getIterator(); + // while(list($tKey, $tMarker) = each($this->aTimeMarks)) foreach ($it as $tKey=>$tMarker) { - + file_put_contents(e_LOG."debugPerformance.log",$tKey."\t". $sMarker."\n", FILE_APPEND); if(!$bRowHeaders) { @@ -585,10 +590,12 @@ // $nextMarker = current($this->aTimeMarks); $it->next(); $nextMarker = $it->current(); + $it->seek($tKey - 1); // go back one position. $aNextT = $nextMarker['Time']; $aThisT = $tMarker['Time']; + $thisDelta = e107::getSingleton('e107_traffic')->TimeDelta($aThisT, $aNextT); $aSum['Time'] += $thisDelta; $aSum['DB Time'] += $tMarker['DB Time']; @@ -598,6 +605,8 @@ $tMarker['%Time'] = $totTime ? number_format(100.0 * ($thisDelta / $totTime), 0) : 0; + $tMarker['%Time'] = $this->highlight($tMarker['%Time'], $tMarker['%Time'], 20); + $tMarker['%DB Count'] = number_format(100.0 * $tMarker['DB Count'] / $sql->db_QueryCount(), 0); $tMarker['%DB Time'] = $db_time ? number_format(100.0 * $tMarker['DB Time'] / $db_time, 0) : 0; $tMarker['DB Time'] = number_format($tMarker['DB Time'] * 1000.0, 1);