r97614 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97613‎ | r97614 | r97615 >
Date:11:06, 20 September 2011
Author:tstarling
Status:ok
Tags:
Comment:
* 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) (history)

Diff [purge]

Index: trunk/phase3/includes/profiler/ProfilerSimple.php
@@ -12,10 +12,20 @@
1313 class ProfilerSimple extends Profiler {
1414 var $mMinimumTime = 0;
1515
 16+ var $zeroEntry = array('cpu'=> 0.0, 'cpu_sq' => 0.0, 'real' => 0.0, 'real_sq' => 0.0, 'count' => 0);
 17+ var $errorEntry;
 18+
1619 function __construct( $params ) {
1720 global $wgRequestTime, $wgRUstart;
1821 parent::__construct( $params );
 22+
 23+ $this->errorEntry = $this->zeroEntry;
 24+ $this->errorEntry['count'] = 1;
 25+
1926 if (!empty($wgRequestTime) && !empty($wgRUstart)) {
 27+ # Remove the -total entry from parent::__construct
 28+ $this->mWorkStack = array();
 29+
2030 $this->mWorkStack[] = array( '-total', 0, $wgRequestTime,$this->getCpuTime($wgRUstart));
2131
2232 $elapsedcpu = $this->getCpuTime() - $this->getCpuTime($wgRUstart);
@@ -23,7 +33,7 @@
2434
2535 $entry =& $this->mCollated["-setup"];
2636 if (!is_array($entry)) {
27 - $entry = array('cpu'=> 0.0, 'cpu_sq' => 0.0, 'real' => 0.0, 'real_sq' => 0.0, 'count' => 0);
 37+ $entry = $this->zeroEntry;
2838 $this->mCollated["-setup"] =& $entry;
2939 }
3040 $entry['cpu'] += $elapsedcpu;
@@ -62,20 +72,18 @@
6373 $message = "Profile section ended by close(): {$ofname}";
6474 $functionname = $ofname;
6575 $this->debug( "$message\n" );
66 - $this->mCollated[$message] = array(
67 - 'real' => 0.0, 'count' => 1);
 76+ $this->mCollated[$message] = $this->errorEntry;
6877 }
6978 elseif ($ofname != $functionname) {
7079 $message = "Profiling error: in({$ofname}), out($functionname)";
7180 $this->debug( "$message\n" );
72 - $this->mCollated[$message] = array(
73 - 'real' => 0.0, 'count' => 1);
 81+ $this->mCollated[$message] = $this->errorEntry;
7482 }
7583 $entry =& $this->mCollated[$functionname];
7684 $elapsedcpu = $this->getCpuTime() - $octime;
7785 $elapsedreal = microtime(true) - $ortime;
7886 if (!is_array($entry)) {
79 - $entry = array('cpu'=> 0.0, 'cpu_sq' => 0.0, 'real' => 0.0, 'real_sq' => 0.0, 'count' => 0);
 87+ $entry = $this->zeroEntry;
8088 $this->mCollated[$functionname] =& $entry;
8189 }
8290 $entry['cpu'] += $elapsedcpu;

Follow-up revisions

RevisionCommit summaryAuthorDate
r97690MFT r97614: fixed ProfilerSimple double-counting of -totaltstarling02:12, 21 September 2011
r984521.18: MFT r97403, r97614, r97657, r97661reedy21:10, 29 September 2011

Status & tagging log