31define(
'MW_NO_SESSION',
'warn' );
33ini_set(
'zlib.output_compression',
'off' );
36require __DIR__ .
'/includes/WebStart.php';
38header(
'Content-Type: text/html; charset=utf-8' );
44 <meta charset=
"UTF-8" />
45 <title>Profiling data</title>
57 font: 14px/1.6 sans-serif;
67 text-decoration:
none;
71 text-decoration: underline;
86 background-
color: transparent;
87 border-collapse: collapse;
101 border-top: 1px solid #ddd;
109 vertical-align: bottom;
112 .table thead:first-child tr:first-child th,
113 .table thead:first-child tr:first-child td {
117 .table tbody + tbody {
118 border-top: 2px solid #ddd;
122 .table-condensed td {
126 .table-striped tbody tr:nth-child(odd) td,
127 .table-striped tbody tr:nth-child(odd) th {
131 .table-hover tbody tr:hover td,
132 .table-hover tbody tr:hover th {
133 background-
color: #f5f5f5;
139 border-top: 1px solid #eee;
140 border-bottom: 1px solid #fff;
148 echo
'<p>Disabled</p>'
155if ( !
$dbr->tableExists(
'profiling' ) ) {
156 echo
'<p>No <code>profiling</code> table exists, so we can\'t show you anything.</p>'
157 .
'<p>If you want to log profiling data, enable <code>$wgProfiler[\'output\'] = \'db\'</code>'
158 .
' in your StartProfiler.php and run <code>maintenance/update.php</code> to'
159 .
' create the profiling table.'
165if ( isset( $_REQUEST[
'expand'] ) ) {
166 foreach ( explode(
',', $_REQUEST[
'expand'] ) as $f ) {
185 $this->memory = $memory;
186 $this->children = [];
190 $this->children[] = $child;
194 usort( $this->children,
'compare_point' );
198 $anchor = str_replace(
'"',
'', $this->
name() );
201 if (
count( $this->children ) ) {
203 $extet =
" <a id=\"{$anchor}\" href=\"{$url}#{$anchor}\">[+]</a>";
209 foreach (
$expand as $name => $ep ) {
210 if ( $name != $this->
name() ) {
211 $e += [ $name => $ep ];
215 $extet =
" <a id=\"{$anchor}\" href=\"{$url}#{$anchor}\">[–]</a>";
220 <
div style=
"margin-left: <?php echo (int)$indent; ?>em;">
221 <?php echo htmlspecialchars( str_replace(
',',
', ', $this->
name() ) ) . $extet ?>
225 <td
class=
"mw-profileinfo-timep"><?php echo @
wfPercent( $this->
time() / self::$totaltime * 100 ); ?></td>
226 <td
class=
"mw-profileinfo-memoryp"><?php echo @
wfPercent( $this->
memory() / self::$totalmemory * 100 ); ?></td>
227 <td
class=
"mw-profileinfo-count"><?php echo $this->
count(); ?></td>
228 <td
class=
"mw-profileinfo-cpr"><?php echo round( sprintf(
'%.2f', $this->
callsPerRequest() ), 2 ); ?></td>
229 <td
class=
"mw-profileinfo-tpc"><?php echo round( sprintf(
'%.2f', $this->
timePerCall() ), 2 ); ?></td>
230 <td
class=
"mw-profileinfo-mpc"><?php echo round( sprintf(
'%.2f', $this->
memoryPerCall() / 1024 ), 2 ); ?></td>
231 <td
class=
"mw-profileinfo-tpr"><?php echo @round( sprintf(
'%.2f', $this->
time() / self::$totalcount ), 2 ); ?></td>
232 <td
class=
"mw-profileinfo-mpr"><?php echo @round( sprintf(
'%.2f', $this->
memory() / self::$totalcount / 1024 ), 2 ); ?></td>
237 foreach ( $this->children as $child ) {
238 $child->display(
$expand, $indent + 2 );
256 return $this->memory;
285 return sprintf(
'%5.02f', $this->time );
295 return strcmp( $a->name(), $b->name() );
297 return $a->time() > $b->time() ? -1 : 1;
299 return $a->memory() > $b->memory() ? -1 : 1;
301 return $a->count() > $b->count() ? -1 : 1;
302 case 'time_per_call':
303 return $a->timePerCall() > $b->timePerCall() ? -1 : 1;
304 case 'memory_per_call':
305 return $a->memoryPerCall() > $b->memoryPerCall() ? -1 : 1;
306 case 'calls_per_req':
307 return $a->callsPerRequest() > $b->callsPerRequest() ? -1 : 1;
309 return $a->timePerRequest() > $b->timePerRequest() ? -1 : 1;
310 case 'memory_per_req':
311 return $a->memoryPerRequest() > $b->memoryPerRequest() ? -1 : 1;
315$sorts = [
'time',
'memory',
'count',
'calls_per_req',
'name',
316 'time_per_call',
'memory_per_call',
'time_per_req',
'memory_per_req' ];
318if ( isset( $_REQUEST[
'sort'] ) && in_array( $_REQUEST[
'sort'],
$sorts ) ) {
319 $sort = $_REQUEST[
'sort'];
327 [
'ORDER BY' =>
'pf_name ASC' ]
330if ( isset( $_REQUEST[
'filter'] ) ) {
331 $filter = $_REQUEST[
'filter'];
337<
form method=
"get" action=
"profileinfo.php">
339 <input
type=
"text" name=
"filter" value=
"<?php echo htmlspecialchars( $filter ); ?>">
340 <input
type=
"hidden" name=
"sort" value=
"<?php echo htmlspecialchars( $sort ); ?>">
341 <input
type=
"hidden" name=
"expand" value=
"<?php
342 echo htmlspecialchars( implode( ",
", array_keys( $expand ) ) );
344 <input
type=
"submit" value=
"Filter">
348<
table class=
"mw-profileinfo-table table table-striped table-hover">
352 echo getEscapedProfileUrl( false, 'name' );
355 echo getEscapedProfileUrl( false, 'time' );
356 ?>">Time (%)</a></th>
358 echo getEscapedProfileUrl( false, 'memory' );
359 ?>">Memory (%)</a></th>
361 echo getEscapedProfileUrl( false, 'count' );
364 echo getEscapedProfileUrl( false, 'calls_per_req' );
365 ?>">Calls/req</a></th>
367 echo getEscapedProfileUrl( false, 'time_per_call' );
370 echo getEscapedProfileUrl( false, 'memory_per_call' );
373 echo getEscapedProfileUrl( false, 'time_per_req' );
376 echo getEscapedProfileUrl( false, 'memory_per_req' );
390 if ( $_expand ===
false ) {
394 return htmlspecialchars(
397 'filter' => $_filter ? $_filter : $filter,
398 'sort' => $_sort ? $_sort :
$sort,
399 'expand' => implode(
',', array_keys( $_expand ) )
409 foreach (
$res as $o ) {
410 $next =
new profile_point( $o->pf_name, $o->pf_count, $o->pf_time, $o->pf_memory );
411 if ( $next->name() ==
'-total' || $next->name() ==
'main()' ) {
416 if (
$last !==
false ) {
417 if ( preg_match(
'/^' . preg_quote(
$last->name(),
'/' ) .
'/', $next->name() ) ) {
418 $last->add_child( $next );
423 if ( preg_match(
'/^query: /', $next->name() ) || preg_match(
'/^query-m: /', $next->name() ) ) {
438 @usort(
$points,
'compare_point' );
440 foreach (
$points as $point ) {
441 if ( strlen( $filter ) && !strstr( $point->name(), $filter ) ) {
in the sidebar</td >< td > font color
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfPercent( $nr, $acc=2, $round=true)
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
display( $expand, $indent=0.0)
__construct( $name, $count, $time, $memory)
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if so it s not worth the trouble Since there is a job queue in the jobs table
null means default in associative array form
> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) name
returning false will NOT prevent logging $e
</source > ! result< div class="mw-highlight mw-content-ltr" dir="ltr">< pre >< span ></span >< span class="kd"> var</span >< span class="nx"> a</span >< span class="p"></span ></pre ></div > !end !test Multiline< source/> in lists !input *< source > a b</source > *foo< source > a b</source > ! html< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > !html tidy< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > !end !test Custom attributes !input< source lang="javascript" id="foo" class="bar" dir="rtl" style="font-size: larger;"> var a
</source > ! result< p > Text< code class="mw-highlight" dir="ltr">< span class="kd"> var</span >< span class="nx"> a</span >< span class="p"></span ></code ></p > !end !test Enclose none(inline code) !!input Text< source lang
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
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
if(isset( $_REQUEST['sort']) &&in_array( $_REQUEST['sort'], $sorts)) $res
compare_point(profile_point $a, profile_point $b)
getEscapedProfileUrl( $_filter=false, $_sort=false, $_expand=false)
if(! $wgEnableProfileInfo) $dbr
if(! $dbr->tableExists( 'profiling')) $expand