77 return $this->sprofiler->scopedProfileIn(
$key );
93 if (
$name ===
'-total' ) {
96 if ( !empty( $this->params[
'include'] ) ) {
97 foreach ( $this->params[
'include']
as $pattern ) {
98 if ( fnmatch( $pattern,
$name, FNM_NOESCAPE ) ) {
104 if ( !empty( $this->params[
'exclude'] ) ) {
105 foreach ( $this->params[
'exclude']
as $pattern ) {
106 if ( fnmatch( $pattern,
$name, FNM_NOESCAPE ) ) {
115 $metrics = $this->xhprof->getCompleteMetrics();
119 foreach ( $metrics
as $fname => $stats ) {
126 'calls' => $stats[
'ct'],
127 'real' => $stats[
'wt'][
'total'] / 1000,
128 '%real' => $stats[
'wt'][
'percent'],
129 'cpu' => isset( $stats[
'cpu'] ) ? $stats[
'cpu'][
'total'] / 1000 : 0,
130 '%cpu' => isset( $stats[
'cpu'] ) ? $stats[
'cpu'][
'percent'] : 0,
131 'memory' => isset( $stats[
'mu'] ) ? $stats[
'mu'][
'total'] : 0,
132 '%memory' => isset( $stats[
'mu'] ) ? $stats[
'mu'][
'percent'] : 0,
133 'min_real' => $stats[
'wt'][
'min'] / 1000,
134 'max_real' => $stats[
'wt'][
'max'] / 1000
137 if (
$fname ===
'main()' ) {
143 foreach ( $this->sprofiler->getFunctionStats()
as $stats ) {
149 $stats[
'%real'] = $main[
'real'] ? $stats[
'real'] / $main[
'real'] * 100 : 0;
150 $stats[
'%cpu'] = $main[
'cpu'] ? $stats[
'cpu'] / $main[
'cpu'] * 100 : 0;
151 $stats[
'%memory'] = $main[
'memory'] ? $stats[
'memory'] / $main[
'memory'] * 100 : 0;
185 usort( $data,
function( $a, $b ) {
186 if ( $a[
'real'] === $b[
'real'] ) {
189 return ( $a[
'real'] > $b[
'real'] ) ? -1 : 1;
193 $nameWidth = $width - 65;
194 $format =
"%-{$nameWidth}s %6d %9d %9d %9d %9d %7.3f%% %9d";
196 $out[] = sprintf(
"%-{$nameWidth}s %6s %9s %9s %9s %9s %7s %9s",
197 'Name',
'Calls',
'Total',
'Min',
'Each',
'Max',
'%',
'Mem'
199 foreach ( $data
as $stats ) {
200 $out[] = sprintf( $format,
203 $stats[
'real'] * 1000,
204 $stats[
'min_real'] * 1000,
205 $stats[
'real'] / $stats[
'calls'] * 1000,
206 $stats[
'max_real'] * 1000,
211 return implode(
"\n",
$out );
219 return $this->xhprof->getRawData();
Convenience class for working with XHProf https://github.com/phacility/xhprof.
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
the array() calling protocol came about after MediaWiki 1.4rc1.
magic word the default is to use $key to get the and $key value or $key value text $key value html to format the value $key
scopedProfileIn($section)
getOutput()
Returns a profiling output to be stored in debug file.
close()
No-op for xhprof profiling.
SectionProfiler $sprofiler
Profiler for explicit, arbitrary, frame labels.
array $params
All of the params passed from $wgProfiler.
__construct(array $params=[])
getFunctionReport()
Get a report of profiled functions sorted by inclusive wall clock time in descending order...
Custom PHP profiler for parser/DB type section names that xhprof/xdebug can't handle.
shouldExclude($name)
Check if a function or section should be excluded from the output.
Profiler wrapper for XHProf extension.
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
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
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
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined...
getRawData()
Retrieve raw data from xhprof.
Profiler base class that defines the interface and some trivial functionality.
Allows to change the fields on the form that will be generated $name