protected $collateOnly = true;
/** @var array Cache of a standard broken collation entry */
protected $errorEntry;
+ /** @var callable Cache of a profile out callback */
+ protected $profileOutCallback;
/**
* @param array $params
public function __construct( array $params = array() ) {
$this->errorEntry = $this->getErrorEntry();
$this->collateOnly = empty( $params['trace'] );
+ $this->profileOutCallback = function ( $profiler, $section ) {
+ $profiler->profileOutInternal( $section );
+ };
}
/**
$this->profileInInternal( $section );
$that = $this;
- return new ScopedCallback( function () use ( $that, $section ) {
- $that->profileOutInternal( $section );
- } );
+ return new ScopedCallback( $this->profileOutCallback, array( $that, $section ) );
}
/**
* - %cpu : percent real time
* - memory : memory used (bytes)
* - %memory : percent memory used
+ * - min_real : min real time in a call (ms)
+ * - max_real : max real time in a call (ms)
*/
public function getFunctionStats() {
$this->collateData();
'%cpu' => $totalCpu ? 100 * $data['cpu'] / $totalCpu : 0,
'memory' => $data['memory'],
'%memory' => $totalMem ? 100 * $data['memory'] / $totalMem : 0,
+ 'min_real' => 1000 * $data['min_real'],
+ 'max_real' => 1000 * $data['max_real']
);
}
'%cpu' => 100,
'memory' => $totalMem,
'%memory' => 100,
+ 'min_real' => 1000 * $totalReal,
+ 'max_real' => 1000 * $totalReal
);
return $profile;
'cpu' => 0.0,
'real' => 0.0,
'memory' => 0,
- 'count' => 0
+ 'count' => 0,
+ 'min_real' => 0.0,
+ 'max_real' => 0.0
);
}
$entry['real'] += $elapsedReal;
$entry['memory'] += $memChange > 0 ? $memChange : 0;
$entry['count']++;
+ $entry['min_real'] = min( $entry['min_real'], $elapsedReal );
+ $entry['max_real'] = max( $entry['max_real'], $elapsedReal );
}
/**