From 013c066015b9131535d6f6848aaded97e3124e65 Mon Sep 17 00:00:00 2001 From: mrpete Date: Sun, 4 Mar 2007 13:42:01 +0000 Subject: [PATCH] Support show-includes list. Performance debug now also shows memory use. --- e107_handlers/db_debug_class.php | 43 +++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/e107_handlers/db_debug_class.php b/e107_handlers/db_debug_class.php index ddb7c2c50..f808d142f 100644 --- a/e107_handlers/db_debug_class.php +++ b/e107_handlers/db_debug_class.php @@ -1,9 +1,9 @@ - 0, 'Time' => ($eTimingStart), 'DB Time' => 0, - 'DB Count' => 0 + 'DB Count' => 0, + 'Memory' => 0 ); register_shutdown_function('e107_debug_shutdown'); @@ -65,6 +66,7 @@ class e107_db_debug { $this->ShowIf('Shortcodes / BBCode',$this->Show_SC_BB()); $this->ShowIf('Paths', $this->Show_PATH()); $this->ShowIf('Deprecated Function Usage', $this->Show_DEPRECATED()); + $this->ShowIf('Included Files', $this->Show_Includes()); } function ShowIf($title,$str) @@ -98,7 +100,8 @@ class e107_db_debug { '%DB Count' => 0, 'Time' => $timeNow, 'DB Time' => 0, - 'DB Count' => 0 + 'DB Count' => 0, + 'Memory' => ((function_exists("memory_get_usage"))? memory_get_usage() : 0) ); $this->aOBMarks[$nMarks]=ob_get_level().'('.ob_get_length().')'; @@ -271,8 +274,9 @@ class e107_db_debug { $aSum['Index']=''; $aSum['What']='Total'; $aSum['Time']=0; - $aSum['DB Count']=0; $aSum['DB Time']=0; + $aSum['DB Count']=0; + $aSum['Memory']=''; while (list($tKey, $tMarker) = each($this->aTimeMarks)) { if (!$bRowHeaders) { @@ -292,9 +296,12 @@ class e107_db_debug { } } $aUnits['OB Lev'] = 'lev(buf bytes)'; + $aUnits['Memory'] = '(kb)'; $text .= "".implode(" ", $aUnits)." \n"; } + $tMem = $tMarker['Memory']; + $tMarker['Memory'] = ($tMem ? number_format($tMem/1024.0, 1) : '?'); // display if known if ($tMarker['What'] == 'Stop') { $tMarker['Time']=' '; $tMarker['%Time']=' '; @@ -303,7 +310,7 @@ class e107_db_debug { $tMarker['DB Time']=' '; $tMarker['OB Lev']=$this->aOBMarks[$tKey]; $tMarker['DB Count']=' '; - } else { + } else { // Convert from start time to delta time, i.e. from now to next entry $nextMarker=current($this->aTimeMarks); $aNextT=$nextMarker['Time']; @@ -318,8 +325,10 @@ class e107_db_debug { $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); + $tMarker['OB Lev']=$this->aOBMarks[$tKey]; } + $text .= "".implode(" ", array_values($tMarker))." \n"; if (isset($this->aMarkNotes[$tKey])) { @@ -550,8 +559,24 @@ class e107_db_debug { return $text; } + + function Show_Includes() + { + if (!E107_DBG_INCLUDES) return FALSE; + + $aIncList = get_included_files(); + $text = "\n"; + $text .= "\n\n"; + $text .= "
". + implode(" 
", $aIncList). + " 
\n"; + return $text; + } } +// +// Helper functions (not part of the class) +// function e107_debug_shutdown() { global $error_handler,$e107_Clean_Exit,$In_e107_Footer,$ADMIN_DIRECTORY; @@ -588,4 +613,4 @@ global $error_handler,$e107_Clean_Exit,$In_e107_Footer,$ADMIN_DIRECTORY; echo ""; } -?> +?> \ No newline at end of file