r48493 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48492‎ | r48493 | r48494 >
Date:19:46, 17 March 2009
Author:midom
Status:ok
Tags:
Comment:
add memory tracing
Modified paths:
  • /trunk/phase3/includes/ProfilerSimpleTrace.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ProfilerSimpleTrace.php
@@ -17,6 +17,7 @@
1818 var $mMinimumTime = 0;
1919 var $mProfileID = false;
2020 var $trace = "";
 21+ var $memory = 0;
2122
2223 function __construct() {
2324 global $wgRequestTime, $wgRUstart;
@@ -31,7 +32,7 @@
3233 function profileIn($functionname) {
3334 global $wgDebugFunctionEntry;
3435 $this->mWorkStack[] = array($functionname, count( $this->mWorkStack ), microtime(true), $this->getCpuTime());
35 - $this->trace .= str_repeat( " ", count($this->mWorkStack) + 14) . " > " . $functionname . "\n";
 36+ $this->trace .= " " . sprintf("%6.1f",$this->memoryDiff()) . str_repeat( " ", count($this->mWorkStack)) . " > " . $functionname . "\n";
3637 }
3738
3839 function profileOut($functionname) {
@@ -56,9 +57,15 @@
5758 }
5859 $elapsedcpu = $this->getCpuTime() - $octime;
5960 $elapsedreal = microtime(true) - $ortime;
60 - $this->trace .= sprintf("%03.6f ",$elapsedreal) . str_repeat(" ",count($this->mWorkStack)+1) . " < " . $functionname . "\n";
 61+ $this->trace .= sprintf("%03.6f %6.1f",$elapsedreal,$this->memoryDiff()) . str_repeat(" ",count($this->mWorkStack)+1) . " < " . $functionname . "\n";
6162 }
6263 }
 64+
 65+ function memoryDiff() {
 66+ $diff = memory_get_usage() - $this->memory;
 67+ $this->memory = memory_get_usage();
 68+ return $diff/1024;
 69+ }
6370
6471 function getOutput() {
6572 print "<!-- \n {$this->trace} \n -->";

Status & tagging log