*/
class Profiler {
protected $mStack = array(), $mWorkStack = array(), $mCollated = array(),
- $mCalls = array(), $mTotals = array();
+ $mCalls = array(), $mTotals = array(), $mPeriods = array();
protected $mTimeMetric = 'wall';
protected $mProfileID = false, $mCollateDone = false, $mTemplated = false;
$this->mMin[$fname] = 1 << 24;
$this->mMax[$fname] = 0;
$this->mOverhead[$fname] = 0;
+ $this->mPeriods[$fname] = array();
}
$this->mCollated[$fname] += $elapsed;
$this->mMin[$fname] = min( $this->mMin[$fname], $elapsed );
$this->mMax[$fname] = max( $this->mMax[$fname], $elapsed );
$this->mOverhead[$fname] += $subcalls;
+ $this->mPeriods[$fname][] = compact( 'start', 'end', 'memory', 'subcalls' );
}
$this->mCalls['-overhead-total'] = $profileCount;
return $prof;
}
+ /**
+ * @return array
+ */
+ public function getRawData() {
+ $this->collateData();
+
+ $profile = array();
+ $total = isset( $this->mCollated['-total'] ) ? $this->mCollated['-total'] : 0;
+ foreach ( $this->mCollated as $fname => $elapsed ) {
+ $periods = array();
+ foreach ( $this->mPeriods[$fname] as $period ) {
+ $period['start'] *= 1000;
+ $period['end'] *= 1000;
+ $periods[] = $period;
+ }
+ $profile[] = array(
+ 'name' => $fname,
+ 'calls' => $this->mCalls[$fname],
+ 'elapsed' => $elapsed * 1000,
+ 'percent' => $total ? 100. * $elapsed / $total : 0,
+ 'memory' => $this->mMemory[$fname],
+ 'min' => $this->mMin[$fname] * 1000,
+ 'max' => $this->mMax[$fname] * 1000,
+ 'overhead' => $this->mOverhead[$fname],
+ 'periods' => $periods,
+ );
+ }
+
+ return $profile;
+ }
+
/**
* Dummy calls to wfProfileIn/wfProfileOut to calculate its overhead
*/