http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97614
Revision: 97614
Author: tstarling
Date: 2011-09-20 11:06:46 +0000 (Tue, 20 Sep 2011)
Log Message:
-----------
* Fixed notices issued from ProfilerSimpleUDP which were due to
ProfilerSimple::profileOut() not adding a complete entry to $this->mCollated
for a profile error.
* Simplified other points in the code where $this->mCollated entries were
added, by using template arrays $this->errorEntry and $this->zeroEntry.
* Fixed double-counting of -total due to a -total entry being added to
$this->mWorkStack both by parent::__construct() and
ProfilerSimple::__construct().
* Tested against 1.18wmf1 only.
Modified Paths:
--------------
trunk/phase3/includes/profiler/ProfilerSimple.php
Modified: trunk/phase3/includes/profiler/ProfilerSimple.php
===================================================================
--- trunk/phase3/includes/profiler/ProfilerSimple.php 2011-09-20 11:06:17 UTC
(rev 97613)
+++ trunk/phase3/includes/profiler/ProfilerSimple.php 2011-09-20 11:06:46 UTC
(rev 97614)
@@ -12,10 +12,20 @@
class ProfilerSimple extends Profiler {
var $mMinimumTime = 0;
+ var $zeroEntry = array('cpu'=> 0.0, 'cpu_sq' => 0.0, 'real' => 0.0,
'real_sq' => 0.0, 'count' => 0);
+ var $errorEntry;
+
function __construct( $params ) {
global $wgRequestTime, $wgRUstart;
parent::__construct( $params );
+
+ $this->errorEntry = $this->zeroEntry;
+ $this->errorEntry['count'] = 1;
+
if (!empty($wgRequestTime) && !empty($wgRUstart)) {
+ # Remove the -total entry from parent::__construct
+ $this->mWorkStack = array();
+
$this->mWorkStack[] = array( '-total', 0,
$wgRequestTime,$this->getCpuTime($wgRUstart));
$elapsedcpu = $this->getCpuTime() -
$this->getCpuTime($wgRUstart);
@@ -23,7 +33,7 @@
$entry =& $this->mCollated["-setup"];
if (!is_array($entry)) {
- $entry = array('cpu'=> 0.0, 'cpu_sq' => 0.0,
'real' => 0.0, 'real_sq' => 0.0, 'count' => 0);
+ $entry = $this->zeroEntry;
$this->mCollated["-setup"] =& $entry;
}
$entry['cpu'] += $elapsedcpu;
@@ -62,20 +72,18 @@
$message = "Profile section ended by close():
{$ofname}";
$functionname = $ofname;
$this->debug( "$message\n" );
- $this->mCollated[$message] = array(
- 'real' => 0.0, 'count' => 1);
+ $this->mCollated[$message] = $this->errorEntry;
}
elseif ($ofname != $functionname) {
$message = "Profiling error: in({$ofname}),
out($functionname)";
$this->debug( "$message\n" );
- $this->mCollated[$message] = array(
- 'real' => 0.0, 'count' => 1);
+ $this->mCollated[$message] = $this->errorEntry;
}
$entry =& $this->mCollated[$functionname];
$elapsedcpu = $this->getCpuTime() - $octime;
$elapsedreal = microtime(true) - $ortime;
if (!is_array($entry)) {
- $entry = array('cpu'=> 0.0, 'cpu_sq' => 0.0,
'real' => 0.0, 'real_sq' => 0.0, 'count' => 0);
+ $entry = $this->zeroEntry;
$this->mCollated[$functionname] =& $entry;
}
$entry['cpu'] += $elapsedcpu;
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs