MediaWiki
REL1_20
|
00001 <?php 00029 class ProfilerSimpleTrace extends ProfilerSimple { 00030 var $trace = "Beginning trace: \n"; 00031 var $memory = 0; 00032 00033 function profileIn( $functionname ) { 00034 parent::profileIn( $functionname ); 00035 $this->trace .= " " . sprintf("%6.1f",$this->memoryDiff()) . 00036 str_repeat( " ", count($this->mWorkStack)) . " > " . $functionname . "\n"; 00037 } 00038 00039 function profileOut($functionname) { 00040 global $wgDebugFunctionEntry; 00041 00042 if ( $wgDebugFunctionEntry ) { 00043 $this->debug(str_repeat(' ', count($this->mWorkStack) - 1).'Exiting '.$functionname."\n"); 00044 } 00045 00046 list( $ofname, /* $ocount */ , $ortime ) = array_pop( $this->mWorkStack ); 00047 00048 if ( !$ofname ) { 00049 $this->trace .= "Profiling error: $functionname\n"; 00050 } else { 00051 if ( $functionname == 'close' ) { 00052 $message = "Profile section ended by close(): {$ofname}"; 00053 $functionname = $ofname; 00054 $this->trace .= $message . "\n"; 00055 } 00056 elseif ( $ofname != $functionname ) { 00057 $this->trace .= "Profiling error: in({$ofname}), out($functionname)"; 00058 } 00059 $elapsedreal = $this->getTime() - $ortime; 00060 $this->trace .= sprintf( "%03.6f %6.1f", $elapsedreal, $this->memoryDiff() ) . 00061 str_repeat(" ", count( $this->mWorkStack ) + 1 ) . " < " . $functionname . "\n"; 00062 } 00063 } 00064 00065 function memoryDiff() { 00066 $diff = memory_get_usage() - $this->memory; 00067 $this->memory = memory_get_usage(); 00068 return $diff / 1024; 00069 } 00070 00071 function logData() { 00072 print "<!-- \n {$this->trace} \n -->"; 00073 } 00074 }