28 ini_set(
'zlib.output_compression',
'off' );
31 require __DIR__ .
'/includes/WebStart.php';
33 header(
'Content-Type: text/html; charset=utf-8' );
39 <meta charset=
"UTF-8" />
52 font: 14px/1.6 sans-serif;
62 text-decoration: none;
66 text-decoration: underline;
81 background-
color: transparent;
82 border-collapse: collapse;
96 border-top: 1px solid #ddd;
104 vertical-align: bottom;
107 .table thead:first-child tr:first-child th,
108 .table thead:first-child tr:first-child td {
112 .table tbody + tbody {
113 border-top: 2px solid #ddd;
117 .table-condensed td {
121 .table-striped tbody tr:nth-child(odd) td,
122 .table-striped tbody tr:nth-child(odd) th {
126 .table-hover tbody tr:hover td,
127 .table-hover tbody tr:hover th {
128 background-
color: #f5f5f5;
134 border-top: 1px solid #eee;
135 border-bottom: 1px solid #fff;
143 echo
'<p>Disabled</p>'
150 if ( !
$dbr->tableExists(
'profiling' ) ) {
151 echo
'<p>No <code>profiling</code> table exists, so we can\'t show you anything.</p>'
152 .
'<p>If you want to log profiling data, enable <code>$wgProfiler[\'output\'] = \'db\'</code>'
153 .
' in your StartProfiler.php and run <code>maintenance/update.php</code> to'
154 .
' create the profiling table.'
160 if ( isset( $_REQUEST[
'expand'] ) ) {
161 foreach ( explode(
',', $_REQUEST[
'expand'] )
as $f ) {
182 $this->children = [];
186 $this->children[] = $child;
190 usort( $this->children,
'compare_point' );
194 $anchor = str_replace(
'"',
'', $this->
name() );
197 if (
count( $this->children ) ) {
199 $extet =
" <a id=\"{$anchor}\" href=\"{$url}#{$anchor}\">[+]</a>";
211 $extet =
" <a id=\"{$anchor}\" href=\"{$url}#{$anchor}\">[–]</a>";
216 <div
style=
"margin-left: <?php echo (int)$indent; ?>em;">
217 <?
php echo htmlspecialchars( str_replace(
',',
', ', $this->
name() ) ) . $extet ?>
221 <td
class=
"mw-profileinfo-timep"><?
php echo @
wfPercent( $this->
time() / self::$totaltime * 100 ); ?></td>
222 <td
class=
"mw-profileinfo-memoryp"><?
php echo @
wfPercent( $this->
memory() / self::$totalmemory * 100 ); ?></td>
223 <td
class=
"mw-profileinfo-count"><?
php echo $this->
count(); ?></td>
224 <td
class=
"mw-profileinfo-cpr"><?
php echo round( sprintf(
'%.2f', $this->
callsPerRequest() ), 2 ); ?></td>
225 <td
class=
"mw-profileinfo-tpc"><?
php echo round( sprintf(
'%.2f', $this->
timePerCall() ), 2 ); ?></td>
226 <td
class=
"mw-profileinfo-mpc"><?
php echo round( sprintf(
'%.2f', $this->
memoryPerCall() / 1024 ), 2 ); ?></td>
227 <td
class=
"mw-profileinfo-tpr"><?
php echo @round( sprintf(
'%.2f', $this->
time() / self::$totalcount ), 2 ); ?></td>
228 <td
class=
"mw-profileinfo-mpr"><?
php echo @round( sprintf(
'%.2f', $this->
memory() / self::$totalcount / 1024 ), 2 ); ?></td>
233 foreach ( $this->children
as $child ) {
234 $child->display(
$expand, $indent + 2 );
252 return $this->memory;
269 return @( $this->
count / self::$totalcount );
275 return @( $this->
time / self::$totalcount );
281 return @( $this->
memory / self::$totalcount );
286 return sprintf(
'%5.02f', $this->
time );
296 return strcmp( $a->
name(), $b->
name() );
298 return $a->
time() > $b->
time() ? -1 : 1;
303 case 'time_per_call':
305 case 'memory_per_call':
307 case 'calls_per_req':
311 case 'memory_per_req':
316 $sorts = [
'time',
'memory',
'count',
'calls_per_req',
'name',
317 'time_per_call',
'memory_per_call',
'time_per_req',
'memory_per_req' ];
319 if ( isset( $_REQUEST[
'sort'] ) && in_array( $_REQUEST[
'sort'],
$sorts ) ) {
320 $sort = $_REQUEST[
'sort'];
328 [
'ORDER BY' =>
'pf_name ASC' ]
331 if ( isset( $_REQUEST[
'filter'] ) ) {
332 $filter = $_REQUEST[
'filter'];
340 <input type=
"text" name=
"filter" value=
"<?php echo htmlspecialchars( $filter ); ?>">
341 <input type=
"hidden" name=
"sort" value=
"<?php echo htmlspecialchars( $sort ); ?>">
342 <input type=
"hidden" name=
"expand" value=
"<?php
343 echo htmlspecialchars( implode( ",
", array_keys( $expand ) ) );
345 <input type=
"submit" value=
"Filter">
349 <table
class=
"mw-profileinfo-table table table-striped table-hover">
353 echo getEscapedProfileUrl( false, 'name' );
356 echo getEscapedProfileUrl( false, 'time' );
357 ?>">Time (%)</a></th>
359 echo getEscapedProfileUrl( false, 'memory' );
360 ?>">Memory (%)</a></th>
362 echo getEscapedProfileUrl( false, 'count' );
365 echo getEscapedProfileUrl( false, 'calls_per_req' );
366 ?>">Calls/req</a></th>
368 echo getEscapedProfileUrl( false, 'time_per_call' );
371 echo getEscapedProfileUrl( false, 'memory_per_call' );
374 echo getEscapedProfileUrl( false, 'time_per_req' );
377 echo getEscapedProfileUrl( false, 'memory_per_req' );
383 profile_point::$totaltime = 0.0;
392 if ( $_expand ===
false ) {
396 return htmlspecialchars(
399 'filter' => $_filter ? $_filter : $filter,
400 'sort' => $_sort ? $_sort : $sort,
401 'expand' => implode(
',', array_keys( $_expand ) )
412 $next =
new profile_point( $o->pf_name, $o->pf_count, $o->pf_time, $o->pf_memory );
413 if ( $next->name() ==
'-total' || $next->name() ==
'main()' ) {
414 profile_point::$totaltime = $next->time();
418 if (
$last !==
false ) {
419 if ( preg_match(
'/^' . preg_quote(
$last->name(),
'/' ) .
'/', $next->name() ) ) {
420 $last->add_child( $next );
425 if ( preg_match(
'/^query: /', $next->name() ) || preg_match(
'/^query-m: /', $next->name() ) ) {
440 @usort(
$points,
'compare_point' );
444 if ( strlen( $filter ) && !strstr( $point->name(), $filter ) ) {
454 <p>Total time: <
code><?
php printf(
'%5.02f', profile_point::$totaltime ); ?></
code></p>
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of data
null means default in associative array form
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
wfPercent($nr, $acc=2, $round=true)
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
when a variable name is used in a it is silently declared as a new local masking the global
display($expand, $indent=0.0)
if(!$dbr->tableExists( 'profiling')) $expand
if(isset($_REQUEST['sort'])&&in_array($_REQUEST['sort'], $sorts)) $res
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like it should help lighten the load on the database servers by caching data and objects in memory
__construct($name, $count, $time, $memory)
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
in the sidebar</td >< td > font color
getEscapedProfileUrl($_filter=false, $_sort=false, $_expand=false)
if(!$wgEnableProfileInfo) $dbr
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
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of or an object and a method hook function The function part of a third party developers and local administrators to define code that will be run at certain points in the mainline code
wfArrayToCgi($array1, $array2=null, $prefix= '')
This function takes one or two arrays as input, and returns a CGI-style string, e.g.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
compare_point(profile_point $a, profile_point $b)