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 if ( $a[
'real'] === $b[
'real'] ) {
207 return ( $a[
'real'] > $b[
'real'] ) ? -1 : 1;
211 $nameWidth = $width - 65;
212 $format =
"%-{$nameWidth}s %6d %9d %9d %9d %9d %7.3f%% %9d";
214 $out[] = sprintf(
"%-{$nameWidth}s %6s %9s %9s %9s %9s %7s %9s",
215 'Name',
'Calls',
'Total',
'Min',
'Each',
'Max',
'%',
'Mem'
217 foreach ( $data as $stats ) {
218 $out[] = sprintf( $format,
221 $stats[
'real'] * 1000,
222 $stats[
'min_real'] * 1000,
223 $stats[
'real'] / $stats[
'calls'] * 1000,
224 $stats[
'max_real'] * 1000,
229 return implode(
"\n",
$out );
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Profiler wrapper for XHProf extension.
getFunctionStats()
Get the aggregated inclusive profiling data for each method.
getRawData()
Retrieve raw data from xhprof.
scopedProfileIn( $section)
Mark the start of a custom profiling frame (e.g.
close()
No-op for xhprof profiling.
__construct(array $params=[])
shouldExclude( $name)
Check if a function or section should be excluded from the output.
getFunctionReport()
Get a report of profiled functions sorted by inclusive wall clock time in descending order.
getOutput()
Returns a profiling output to be stored in debug file.
SectionProfiler $sprofiler
Profiler for explicit, arbitrary, frame labels.
Profiler base class that defines the interface and some trivial functionality.
array $params
All of the params passed from $wgProfiler.
Custom PHP profiler for parser/DB type section names that xhprof/xdebug can't handle.
Convenience class for working with XHProf profiling data https://github.com/phacility/xhprof.
static enable( $flags=0, $options=[])
Start xhprof profiler.
static disable()
Stop xhprof profiler.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section