Revision: 48493
Author: midom
Date: 2009-03-17 19:46:05 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
add memory tracing
Modified Paths:
--------------
trunk/phase3/includes/ProfilerSimpleTrace.php
Modified: trunk/phase3/includes/ProfilerSimpleTrace.php
===================================================================
--- trunk/phase3/includes/ProfilerSimpleTrace.php 2009-03-17 18:15:40 UTC
(rev 48492)
+++ trunk/phase3/includes/ProfilerSimpleTrace.php 2009-03-17 19:46:05 UTC
(rev 48493)
@@ -17,6 +17,7 @@
var $mMinimumTime = 0;
var $mProfileID = false;
var $trace = "";
+ var $memory = 0;
function __construct() {
global $wgRequestTime, $wgRUstart;
@@ -31,7 +32,7 @@
function profileIn($functionname) {
global $wgDebugFunctionEntry;
$this->mWorkStack[] = array($functionname, count(
$this->mWorkStack ), microtime(true), $this->getCpuTime());
- $this->trace .= str_repeat( " ", count($this->mWorkStack) + 14)
. " > " . $functionname . "\n";
+ $this->trace .= " " .
sprintf("%6.1f",$this->memoryDiff()) . str_repeat( " ",
count($this->mWorkStack)) . " > " . $functionname . "\n";
}
function profileOut($functionname) {
@@ -56,9 +57,15 @@
}
$elapsedcpu = $this->getCpuTime() - $octime;
$elapsedreal = microtime(true) - $ortime;
- $this->trace .= sprintf("%03.6f ",$elapsedreal) .
str_repeat(" ",count($this->mWorkStack)+1) . " < " . $functionname . "\n";
+ $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();
+ return $diff/1024;
+ }
function getOutput() {
print "<!-- \n {$this->trace} \n -->";
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs