Go to the documentation of this file.
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 );
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.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
static disable()
Stop xhprof profiler.
close()
No-op for xhprof profiling.
Allows to change the fields on the form that will be generated $name
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
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.
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
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
array $params
All of the params passed from $wgProfiler.
__construct(array $params=[])
it s the revision text itself In either if gzip is the revision text is gzipped $flags
shouldExclude( $name)
Check if a function or section should be excluded from the output.
the array() calling protocol came about after MediaWiki 1.4rc1.
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