MediaWiki REL1_33
ProfilerOutputText.php
Go to the documentation of this file.
1<?php
32 protected $thresholdMs;
33
35 parent::__construct( $collector, $params );
36 $this->thresholdMs = $params['thresholdMs'] ?? 1.0;
37 }
38
39 public function logsToOutput() {
40 return true;
41 }
42
43 public function log( array $stats ) {
44 if ( $this->collector->getTemplated() ) {
45 $out = '';
46
47 // Filter out really tiny entries
48 $min = $this->thresholdMs;
49 $stats = array_filter( $stats, function ( $a ) use ( $min ) {
50 return $a['real'] > $min;
51 } );
52 // Sort descending by time elapsed
53 usort( $stats, function ( $a, $b ) {
54 return $b['real'] <=> $a['real'];
55 } );
56
57 array_walk( $stats,
58 function ( $item ) use ( &$out ) {
59 $out .= sprintf( "%6.2f%% %3.3f %6d - %s\n",
60 $item['%real'], $item['real'], $item['calls'], $item['name'] );
61 }
62 );
63
64 $contentType = $this->collector->getContentType();
65 if ( wfIsCLI() ) {
66 print "<!--\n{$out}\n-->\n";
67 } elseif ( $contentType === 'text/html' ) {
68 $visible = $this->params['visible'] ?? false;
69 if ( $visible ) {
70 print "<pre>{$out}</pre>";
71 } else {
72 print "<!--\n{$out}\n-->\n";
73 }
74 } elseif ( $contentType === 'text/javascript' || $contentType === 'text/css' ) {
75 print "\n/*\n{$out}*/\n";
76 }
77 }
78 }
79}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfIsCLI()
Check if we are running from the commandline.
The least sophisticated profiler output class possible, view your source! :)
float $thresholdMs
Min real time display threshold.
log(array $stats)
Log MediaWiki-style profiling data.
logsToOutput()
Does log() just send the data to the request/script output?
__construct(Profiler $collector, array $params)
Base class for profiling output.
array $params
Configuration of $wgProfiler.
Profiler base class that defines the interface and some trivial functionality.
Definition Profiler.php:33
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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
Definition hooks.txt:855
while(( $__line=Maintenance::readconsole()) !==false) print
Definition eval.php:64
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))