$this->mProfileID = $params['profileID'];
}
- // Push an entry for the pre-profile setup time onto the stack
- $initial = $this->getInitialTime();
- if ( $initial !== null ) {
- $this->mWorkStack[] = array( '-total', 0, $initial, 0 );
- $this->mStack[] = array( '-setup', 1, $initial, 0, $this->getTime(), 0 );
- } else {
- $this->profileIn( '-total' );
- }
+ $this->addInitialStack();
}
/**
}
}
+ /**
+ * Add the inital item in the stack.
+ */
+ protected function addInitialStack() {
+ // Push an entry for the pre-profile setup time onto the stack
+ $initial = $this->getInitialTime();
+ if ( $initial !== null ) {
+ $this->mWorkStack[] = array( '-total', 0, $initial, 0 );
+ $this->mStack[] = array( '-setup', 1, $initial, 0, $this->getTime(), 0 );
+ } else {
+ $this->profileIn( '-total' );
+ }
+ }
+
/**
* Called by wfProfieIn()
*
var $zeroEntry = array('cpu'=> 0.0, 'cpu_sq' => 0.0, 'real' => 0.0, 'real_sq' => 0.0, 'count' => 0);
var $errorEntry;
- function __construct( $params ) {
+ protected function addInitialStack() {
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();
+ if ( !empty( $wgRequestTime ) && !empty( $wgRUstart ) ) {
+ $initialCpu = $this->getCpuTime( $wgRUstart );
+ $this->mWorkStack[] = array( '-total', 0, $wgRequestTime, $initialCpu );
+ $this->mWorkStack[] = array( '-setup', 1, $wgRequestTime, $initialCpu );
- $this->mWorkStack[] = array( '-total', 0, $wgRequestTime,$this->getCpuTime($wgRUstart));
-
- $elapsedcpu = $this->getCpuTime() - $this->getCpuTime($wgRUstart);
- $elapsedreal = microtime(true) - $wgRequestTime;
-
- $entry =& $this->mCollated["-setup"];
- if (!is_array($entry)) {
- $entry = $this->zeroEntry;
- $this->mCollated["-setup"] =& $entry;
- }
- $entry['cpu'] += $elapsedcpu;
- $entry['cpu_sq'] += $elapsedcpu*$elapsedcpu;
- $entry['real'] += $elapsedreal;
- $entry['real_sq'] += $elapsedreal*$elapsedreal;
- $entry['count']++;
+ $this->profileOut( '-setup' );
+ } else {
+ $this->profileIn( '-total' );
}
}