Index: trunk/phase3/includes/ProfilerSimpleTrace.php |
— | — | @@ -17,6 +17,7 @@ |
18 | 18 | var $mMinimumTime = 0; |
19 | 19 | var $mProfileID = false; |
20 | 20 | var $trace = ""; |
| 21 | + var $memory = 0; |
21 | 22 | |
22 | 23 | function __construct() { |
23 | 24 | global $wgRequestTime, $wgRUstart; |
— | — | @@ -31,7 +32,7 @@ |
32 | 33 | function profileIn($functionname) { |
33 | 34 | global $wgDebugFunctionEntry; |
34 | 35 | $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"; |
36 | 37 | } |
37 | 38 | |
38 | 39 | function profileOut($functionname) { |
— | — | @@ -56,9 +57,15 @@ |
57 | 58 | } |
58 | 59 | $elapsedcpu = $this->getCpuTime() - $octime; |
59 | 60 | $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"; |
61 | 62 | } |
62 | 63 | } |
| 64 | + |
| 65 | + function memoryDiff() { |
| 66 | + $diff = memory_get_usage() - $this->memory; |
| 67 | + $this->memory = memory_get_usage(); |
| 68 | + return $diff/1024; |
| 69 | + } |
63 | 70 | |
64 | 71 | function getOutput() { |
65 | 72 | print "<!-- \n {$this->trace} \n -->"; |