9 * @todo document methods (?)
12 class ProfilerSimpleTrace
extends ProfilerSimple
{
13 var $trace = "Beginning trace: \n";
16 function profileIn( $functionname ) {
17 parent
::profileIn( $functionname );
18 $this->trace
.= " " . sprintf("%6.1f",$this->memoryDiff()) .
19 str_repeat( " ", count($this->mWorkStack
)) . " > " . $functionname . "\n";
22 function profileOut($functionname) {
23 global $wgDebugFunctionEntry;
25 if ( $wgDebugFunctionEntry ) {
26 $this->debug(str_repeat(' ', count($this->mWorkStack
) - 1).'Exiting '.$functionname."\n");
29 list( $ofname, /* $ocount */ , $ortime ) = array_pop( $this->mWorkStack
);
32 $this->trace
.= "Profiling error: $functionname\n";
34 if ( $functionname == 'close' ) {
35 $message = "Profile section ended by close(): {$ofname}";
36 $functionname = $ofname;
37 $this->trace
.= $message . "\n";
39 elseif ( $ofname != $functionname ) {
40 $this->trace
.= "Profiling error: in({$ofname}), out($functionname)";
42 $elapsedreal = $this->getTime() - $ortime;
43 $this->trace
.= sprintf( "%03.6f %6.1f", $elapsedreal, $this->memoryDiff() ) .
44 str_repeat(" ", count( $this->mWorkStack
) +
1 ) . " < " . $functionname . "\n";
48 function memoryDiff() {
49 $diff = memory_get_usage() - $this->memory
;
50 $this->memory
= memory_get_usage();
55 print "<!-- \n {$this->trace} \n -->";