X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fprofiler%2FProfilerSimpleTrace.php;h=2a4449483c577602a61bc761cfc8d8f0fd0a09e7;hb=3c65da7e737a23b99d354b160f665e4c47d35876;hp=d44dfe1bcb6ad0991bc6d6a3c7dbaca5fd189868;hpb=be6a0c59043e24a199662f8ca596842ab56b2e58;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/profiler/ProfilerSimpleTrace.php b/includes/profiler/ProfilerSimpleTrace.php index d44dfe1bcb..2a4449483c 100644 --- a/includes/profiler/ProfilerSimpleTrace.php +++ b/includes/profiler/ProfilerSimpleTrace.php @@ -22,61 +22,64 @@ */ /** - * Execution trace + * Execution trace profiler * @todo document methods (?) * @ingroup Profiler */ -class ProfilerSimpleTrace extends ProfilerSimple { - var $trace = "Beginning trace: \n"; - var $memory = 0; +class ProfilerSimpleTrace extends ProfilerStandard { + protected $trace = "Beginning trace: \n"; + protected $memory = 0; - function profileIn( $functionname ) { + protected function collateOnly() { + return true; + } + + public function profileIn( $functionname ) { parent::profileIn( $functionname ); + $this->trace .= " " . sprintf( "%6.1f", $this->memoryDiff() ) . - str_repeat( " ", count( $this->mWorkStack ) ) . " > " . $functionname . "\n"; + str_repeat( " ", count( $this->mWorkStack ) ) . " > " . $functionname . "\n"; } - function profileOut( $functionname ) { - global $wgDebugFunctionEntry; + public function profileOut( $functionname ) { + $item = end( $this->mWorkStack ); - if ( $wgDebugFunctionEntry ) { - $this->debug( str_repeat( ' ', count( $this->mWorkStack ) - 1 ) . 'Exiting ' . $functionname . "\n" ); - } + parent::profileOut( $functionname ); - list( $ofname, /* $ocount */, $ortime ) = array_pop( $this->mWorkStack ); - - if ( !$ofname ) { + if ( !$item ) { $this->trace .= "Profiling error: $functionname\n"; } else { + list( $ofname, /* $ocount */, $ortime ) = $item; if ( $functionname == 'close' ) { $message = "Profile section ended by close(): {$ofname}"; $functionname = $ofname; $this->trace .= $message . "\n"; - } - elseif ( $ofname != $functionname ) { + } elseif ( $ofname != $functionname ) { $this->trace .= "Profiling error: in({$ofname}), out($functionname)"; } $elapsedreal = $this->getTime() - $ortime; $this->trace .= sprintf( "%03.6f %6.1f", $elapsedreal, $this->memoryDiff() ) . - str_repeat( " ", count( $this->mWorkStack ) + 1 ) . " < " . $functionname . "\n"; + str_repeat( " ", count( $this->mWorkStack ) + 1 ) . " < " . $functionname . "\n"; } } - function memoryDiff() { + protected function memoryDiff() { $diff = memory_get_usage() - $this->memory; $this->memory = memory_get_usage(); return $diff / 1024; } - function logData() { - if ( PHP_SAPI === 'cli' ) { - print ""; - } elseif ( $this->getContentType() === 'text/html' ) { - print ""; - } elseif ( $this->getContentType() === 'text/javascript' ) { - print "\n/*\n {$this->trace}\n*/"; - } elseif ( $this->getContentType() === 'text/css' ) { - print "\n/*\n {$this->trace}\n*/"; + public function logData() { + if ( $this->mTemplated ) { + if ( PHP_SAPI === 'cli' ) { + print ""; + } elseif ( $this->getContentType() === 'text/html' ) { + print ""; + } elseif ( $this->getContentType() === 'text/javascript' ) { + print "\n/*\n {$this->trace}\n*/"; + } elseif ( $this->getContentType() === 'text/css' ) { + print "\n/*\n {$this->trace}\n*/"; + } } } }