diff options
Diffstat (limited to 'includes/profiler/ProfilerSimpleTrace.php')
-rw-r--r-- | includes/profiler/ProfilerSimpleTrace.php | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/includes/profiler/ProfilerSimpleTrace.php b/includes/profiler/ProfilerSimpleTrace.php index 784609f5..822e9fe4 100644 --- a/includes/profiler/ProfilerSimpleTrace.php +++ b/includes/profiler/ProfilerSimpleTrace.php @@ -1,5 +1,22 @@ <?php /** + * Profiler showing execution trace. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * * @file * @ingroup Profiler */ @@ -10,20 +27,11 @@ * @ingroup Profiler */ class ProfilerSimpleTrace extends ProfilerSimple { - var $trace = ""; + var $trace = "Beginning trace: \n"; var $memory = 0; - function __construct( $params ) { - global $wgRequestTime, $wgRUstart; - parent::__construct( $params ); - if ( !empty( $wgRequestTime ) && !empty( $wgRUstart ) ) { - $this->mWorkStack[] = array( '-total', 0, $wgRequestTime, $this->getCpuTime( $wgRUstart ) ); - } - $this->trace .= "Beginning trace: \n"; - } - - function profileIn($functionname) { - $this->mWorkStack[] = array($functionname, count( $this->mWorkStack ), microtime(true), $this->getCpuTime()); + function profileIn( $functionname ) { + parent::profileIn( $functionname ); $this->trace .= " " . sprintf("%6.1f",$this->memoryDiff()) . str_repeat( " ", count($this->mWorkStack)) . " > " . $functionname . "\n"; } @@ -48,12 +56,12 @@ class ProfilerSimpleTrace extends ProfilerSimple { elseif ( $ofname != $functionname ) { $this->trace .= "Profiling error: in({$ofname}), out($functionname)"; } - $elapsedreal = microtime( true ) - $ortime; + $elapsedreal = $this->getTime() - $ortime; $this->trace .= sprintf( "%03.6f %6.1f", $elapsedreal, $this->memoryDiff() ) . str_repeat(" ", count( $this->mWorkStack ) + 1 ) . " < " . $functionname . "\n"; } } - + function memoryDiff() { $diff = memory_get_usage() - $this->memory; $this->memory = memory_get_usage(); |