Go to the documentation of this file.
77 $options = isset(
$params[
'exclude'] )
78 ? [
'ignored_functions' =>
$params[
'exclude'] ] : [];
87 if ( !$this->xhprofData ) {
94 $key =
'section.' . ltrim( $section,
'.' );
95 return $this->sprofiler->scopedProfileIn( $key );
111 if ( $name ===
'-total' ) {
114 if ( !empty( $this->params[
'include'] ) ) {
115 foreach ( $this->params[
'include'] as $pattern ) {
116 if ( fnmatch( $pattern, $name, FNM_NOESCAPE ) ) {
122 if ( !empty( $this->params[
'exclude'] ) ) {
123 foreach ( $this->params[
'exclude'] as $pattern ) {
124 if ( fnmatch( $pattern, $name, FNM_NOESCAPE ) ) {
137 foreach ( $metrics as $fname => $stats ) {
144 'calls' => $stats[
'ct'],
145 'real' => $stats[
'wt'][
'total'] / 1000,
146 '%real' => $stats[
'wt'][
'percent'],
147 'cpu' => isset( $stats[
'cpu'] ) ? $stats[
'cpu'][
'total'] / 1000 : 0,
148 '%cpu' => isset( $stats[
'cpu'] ) ? $stats[
'cpu'][
'percent'] : 0,
149 'memory' => isset( $stats[
'mu'] ) ? $stats[
'mu'][
'total'] : 0,
150 '%memory' => isset( $stats[
'mu'] ) ? $stats[
'mu'][
'percent'] : 0,
151 'min_real' => $stats[
'wt'][
'min'] / 1000,
152 'max_real' => $stats[
'wt'][
'max'] / 1000
155 if ( $fname ===
'main()' ) {
161 foreach ( $this->sprofiler->getFunctionStats() as $stats ) {
167 $stats[
'%real'] = $main[
'real'] ? $stats[
'real'] / $main[
'real'] * 100 : 0;
168 $stats[
'%cpu'] = $main[
'cpu'] ? $stats[
'cpu'] / $main[
'cpu'] * 100 : 0;
169 $stats[
'%memory'] = $main[
'memory'] ? $stats[
'memory'] / $main[
'memory'] * 100 : 0;
203 usort( $data,
function ( $a, $b ) {
204 return $b[
'real'] <=> $a[
'real'];
208 $nameWidth = $width - 65;
209 $format =
"%-{$nameWidth}s %6d %9d %9d %9d %9d %7.3f%% %9d";
211 $out[] = sprintf(
"%-{$nameWidth}s %6s %9s %9s %9s %9s %7s %9s",
212 'Name',
'Calls',
'Total',
'Min',
'Each',
'Max',
'%',
'Mem'
214 foreach ( $data as $stats ) {
215 $out[] = sprintf( $format,
218 $stats[
'real'] * 1000,
219 $stats[
'min_real'] * 1000,
220 $stats[
'real'] / $stats[
'calls'] * 1000,
221 $stats[
'max_real'] * 1000,
226 return implode(
"\n", $out );
scopedProfileIn( $section)
Mark the start of a custom profiling frame (e.g.
Profiler wrapper for XHProf extension.
getOutput()
Returns a profiling output to be stored in debug file.
static enable( $flags=0, $options=[])
Start xhprof profiler.
static disable()
Stop xhprof profiler.
close()
No-op for xhprof profiling.
getFunctionReport()
Get a report of profiled functions sorted by inclusive wall clock time in descending order.
Profiler base class that defines the interface and some trivial functionality.
Custom PHP profiler for parser/DB type section names that xhprof/xdebug can't handle.
SectionProfiler $sprofiler
Profiler for explicit, arbitrary, frame labels.
getRawData()
Retrieve raw data from xhprof.
getFunctionStats()
Get the aggregated inclusive profiling data for each method.
Convenience class for working with XHProf profiling data https://github.com/phacility/xhprof.
array $params
All of the params passed from $wgProfiler.
__construct(array $params=[])
shouldExclude( $name)
Check if a function or section should be excluded from the output.