diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
commit | c9aa36da061816dee256a979c2ff8d2ee41824d9 (patch) | |
tree | 29f7002b80ee984b488bd047dbbd80b36bf892e9 /includes/profiler/ProfilerSimpleTrace.php | |
parent | b4274e0e33eafb5e9ead9d949ebf031a9fb8363b (diff) | |
parent | d1ba966140d7a60cd5ae4e8667ceb27c1a138592 (diff) |
Merge branch 'archwiki'
# Conflicts:
# skins/ArchLinux.php
# skins/ArchLinux/archlogo.gif
Diffstat (limited to 'includes/profiler/ProfilerSimpleTrace.php')
-rw-r--r-- | includes/profiler/ProfilerSimpleTrace.php | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/includes/profiler/ProfilerSimpleTrace.php b/includes/profiler/ProfilerSimpleTrace.php index 5588d1e2..2a444948 100644 --- a/includes/profiler/ProfilerSimpleTrace.php +++ b/includes/profiler/ProfilerSimpleTrace.php @@ -22,63 +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; - - if ( $wgDebugFunctionEntry ) { - $this->debug( str_repeat( ' ', count( $this->mWorkStack ) - 1 ) . 'Exiting ' . $functionname . "\n" ); - } + public function profileOut( $functionname ) { + $item = end( $this->mWorkStack ); - list( $ofname, /* $ocount */, $ortime ) = array_pop( $this->mWorkStack ); + parent::profileOut( $functionname ); - 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"; - - $this->updateTrxProfiling( $functionname, $elapsedreal ); + 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 "<!-- \n {$this->trace} \n -->"; - } elseif ( $this->getContentType() === 'text/html' ) { - print "<!-- \n {$this->trace} \n -->"; - } 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 "<!-- \n {$this->trace} \n -->"; + } elseif ( $this->getContentType() === 'text/html' ) { + print "<!-- \n {$this->trace} \n -->"; + } elseif ( $this->getContentType() === 'text/javascript' ) { + print "\n/*\n {$this->trace}\n*/"; + } elseif ( $this->getContentType() === 'text/css' ) { + print "\n/*\n {$this->trace}\n*/"; + } } } } |