Index: trunk/kernel/include/debugger.php
===================================================================
diff -u -r1349 -r1645
--- trunk/kernel/include/debugger.php (.../debugger.php) (revision 1349)
+++ trunk/kernel/include/debugger.php (.../debugger.php) (revision 1645)
@@ -1,5 +1,5 @@
profileStart('kernel4_startup', 'Startup and Initialization of kernel4');
+ $this->profileStart('script_runtime', 'Script runtime');
ini_set('display_errors',dbg_ConstOn('DBG_ZEND_PRESENT')?0:1);
$this->memoryUsage['error_handling']=0; // memory amount used by error handler
$this->appendRequest();
@@ -296,6 +302,12 @@
$this->Data[] = Array('trace' => $trace, 'debug_type' => 'trace');
}
+ function appendMemoryUsage($msg, $used=null)
+ {
+ if (!isset($used)) $used = round(memory_get_usage()/1024);
+ $this->appendHTML('Memory usage '.$msg.' '.$used.'Kb');
+ }
+
function appendHTML($html)
{
$this->Data[] = Array('html' => $html,'debug_type' => 'html');
@@ -404,6 +416,17 @@
$this->ProfilerData[$key]['ends'] = $this->getMoment();
}
+ function profilerAddTotal($total_key, $key=null, $value=null)
+ {
+ if (!isset($this->ProfilerTotals[$total_key])) {
+ $this->ProfilerTotals[$total_key] = 0;
+ }
+ if (!isset($value)) {
+ $value = $this->ProfilerData[$key]['ends'] - $this->ProfilerData[$key]['begins'];
+ }
+ $this->ProfilerTotals[$total_key] += $value;
+ }
+
function getMoment()
{
list($usec, $sec) = explode(' ', microtime());
@@ -461,9 +484,10 @@
*/
function printReport($returnResult = false)
{
+ $this->profileFinish('script_runtime');
if( dbg_ConstOn('DBG_ZEND_PRESENT') ) return;
dbg_safeDefine('DBG_RAISE_ON_WARNINGS',0);
- dbg_safeDefine('DBG_WINDOW_WIDTH', 500);
+ dbg_safeDefine('DBG_WINDOW_WIDTH', 700);
$this->memoryUsage['debugger_start']=memory_get_usage();
@@ -474,6 +498,14 @@
$this->appendHTML('Hide Debugger');
$this->moveToBegin(1);
+ if ( dbg_ConstOn('DBG_SQL_PROFILE') ) {
+ $this->appendHTML('SQL Total time: '.$this->ProfilerTotals['sql']);
+ }
+
+ if ( dbg_ConstOn('DBG_PROFILE_MEMORY') ) {
+ $this->appendHTML('Memory used by Objects: '.round($this->ProfilerTotals['objects']/1024, 2).'Kb');
+ }
+
if ( dbg_ConstOn('DBG_INCLUDED_FILES') ) {
$files = get_included_files();
$this->appendHTML('Included files:');
@@ -483,7 +515,32 @@
}
}
+ if ( dbg_ConstOn('DBG_PROFILE_INCLUDES') ) {
+ $this->appendHTML('Included files statistics:'.( dbg_ConstOn('DBG_SORT_INCLUDES_MEM') ? ' (sorted by memory usage)':''));
+ $totals = Array( 'mem' => 0, 'time' => 0);
+ $totals_configs = Array( 'mem' => 0, 'time' => 0);
+ if ( dbg_ConstOn('DBG_SORT_INCLUDES_MEM') ) {
+ array_multisort($this->IncludesData['mem'], SORT_DESC, $this->IncludesData['file'], $this->IncludesData['time'], $this->IncludesData['level']);
+ }
+ foreach ($this->IncludesData['file'] as $key => $file_name) {
+ $this->appendHTML( str_repeat(' -> ', ($this->IncludesData['level'][$key] >= 0 ? $this->IncludesData['level'][$key] : 0)).$file_name.' Mem: '.sprintf("%.4f Kb", $this->IncludesData['mem'][$key]/1024).' Time: '.sprintf("%.4f", $this->IncludesData['time'][$key]));
+ if ($this->IncludesData['level'][$key] == 0) {
+ $totals['mem'] += $this->IncludesData['mem'][$key];
+ $totals['time'] += $this->IncludesData['time'][$key];
+ }
+ else if ($this->IncludesData['level'][$key] == -1) {
+ $totals_configs['mem'] += $this->IncludesData['mem'][$key];
+ $totals_configs['time'] += $this->IncludesData['time'][$key];
+ }
+ }
+ $this->appendHTML('Sub-Total classes: '.' Mem: '.sprintf("%.4f Kb", $totals['mem']/1024).' Time: '.sprintf("%.4f", $totals['time']));
+ $this->appendHTML('Sub-Total configs: '.' Mem: '.sprintf("%.4f Kb", $totals_configs['mem']/1024).' Time: '.sprintf("%.4f", $totals_configs['time']));
+ $this->appendHTML('Grand Total: '.' Mem: '.sprintf("%.4f Kb", ($totals['mem']+$totals_configs['mem'])/1024).' Time: '.sprintf("%.4f", $totals['time']+$totals_configs['time']));
+
+
+ }
+
$i = 0; $lineCount = count($this->Data);
ob_start();
?>
@@ -797,6 +854,7 @@
$pos++;
$errline = substr($tmpStr,$pos,strpos($tmpStr,')',$pos)-$pos);
}
+ // if($this->TraceNextError || $errno == E_USER_ERROR)
if($this->TraceNextError)
{
$this->appendTrace();
@@ -857,6 +915,8 @@
$debugger = new Debugger();
if(dbg_ConstOn('DBG_HANDLE_ERRORS')) set_error_handler( array(&$debugger,'saveError') );
- if(dbg_ConstOn('DBG_USE_SHUTDOWN_FUNC')) register_shutdown_function( array(&$debugger,'printReport') );
+ if(dbg_ConstOn('DBG_USE_SHUTDOWN_FUNC')) {
+ register_shutdown_function( array(&$debugger,'printReport') );
+ }
}
?>
\ No newline at end of file