9 * @todo document methods (?)
12 class ProfilerSimpleTrace
extends ProfilerSimple
{
13 var $mMinimumTime = 0;
17 function __construct( $params ) {
18 global $wgRequestTime, $wgRUstart;
19 parent
::__construct( $params );
20 if ( !empty( $wgRequestTime ) && !empty( $wgRUstart ) ) {
21 $this->mWorkStack
[] = array( '-total', 0, $wgRequestTime, $this->getCpuTime( $wgRUstart ) );
23 $this->trace
.= "Beginning trace: \n";
26 function profileIn($functionname) {
27 $this->mWorkStack
[] = array($functionname, count( $this->mWorkStack
), microtime(true), $this->getCpuTime());
28 $this->trace
.= " " . sprintf("%6.1f",$this->memoryDiff()) .
29 str_repeat( " ", count($this->mWorkStack
)) . " > " . $functionname . "\n";
32 function profileOut($functionname) {
33 global $wgDebugFunctionEntry;
35 if ( $wgDebugFunctionEntry ) {
36 $this->debug(str_repeat(' ', count($this->mWorkStack
) - 1).'Exiting '.$functionname."\n");
39 list( $ofname, /* $ocount */ , $ortime ) = array_pop( $this->mWorkStack
);
42 $this->trace
.= "Profiling error: $functionname\n";
44 if ( $functionname == 'close' ) {
45 $message = "Profile section ended by close(): {$ofname}";
46 $functionname = $ofname;
47 $this->trace
.= $message . "\n";
49 elseif ( $ofname != $functionname ) {
50 $this->trace
.= "Profiling error: in({$ofname}), out($functionname)";
52 $elapsedreal = microtime( true ) - $ortime;
53 $this->trace
.= sprintf( "%03.6f %6.1f", $elapsedreal, $this->memoryDiff() ) .
54 str_repeat(" ", count( $this->mWorkStack
) +
1 ) . " < " . $functionname . "\n";
58 function memoryDiff() {
59 $diff = memory_get_usage() - $this->memory
;
60 $this->memory
= memory_get_usage();
65 print "<!-- \n {$this->trace} \n -->";