Go to the documentation of this file.
24 use Wikimedia\ScopedCallback;
51 if ( isset(
$params[
'profileID'] ) ) {
52 $this->profileID =
$params[
'profileID'];
63 if ( self::$instance ===
null ) {
67 'class' =>
'ProfilerStub',
76 $inSample = mt_rand( 0,
$params[
'sampling'] - 1 ) === 0;
77 if ( PHP_SAPI ===
'cli' || !$inSample ) {
78 $params[
'class'] =
'ProfilerStub';
81 if ( !is_array(
$params[
'output'] ) ) {
98 if ( self::$instance && !( self::$instance instanceof
ProfilerStub ) ) {
99 throw new MWException(
'Could not replace non-stub profiler instance.' );
101 self::$instance = $profiler;
109 $this->profileID = $id;
116 if ( $this->profileID ===
false ) {
140 if ( $this->context ) {
143 wfDebug( __METHOD__ .
" called and \$context is null. " .
144 "Return RequestContext::getMain(); for sanity\n" );
184 abstract public function close();
195 foreach ( $this->params[
'output']
as $outputType ) {
199 $outputClass = strpos( $outputType,
'ProfilerOutput' ) ===
false
200 ?
'ProfilerOutput' . ucfirst( $outputType )
202 if ( !class_exists( $outputClass ) ) {
203 throw new MWException(
"'$outputType' is an invalid output type" );
205 $outputInstance =
new $outputClass( $this, $this->params );
206 if ( $outputInstance->canUse() ) {
207 $outputs[] = $outputInstance;
221 $timeElapsed =
$request->getElapsedTime();
222 $timeElapsedThreshold = $this->params[
'threshold'];
223 if ( $timeElapsed <= $timeElapsedThreshold ) {
248 $output->log( $stats );
261 if ( preg_match(
'#^content-type: (\w+/\w+);?#i',
$header, $m ) ) {
274 $this->templated =
$t;
$wgProfileLimit
Only record profiling info for pages that took longer than this.
getTemplated()
Was this call as templated or not.
setTemplated( $t)
Mark this call as templated or not.
static replaceStubInstance(Profiler $profiler)
Replace the current profiler with $profiler if no non-stub profiler is set.
static instance()
Singleton.
getOutput()
Returns a profiling output to be stored in debug file.
getContentType()
Get the content type sent out to the client.
static Profiler $instance
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Stub profiler that does nothing.
string bool $profileID
Profiler ID for bucketing data.
IContextSource $context
Current request context.
scopedProfileIn( $section)
Mark the start of a custom profiling frame (e.g.
The least sophisticated profiler output class possible, view your source! :)
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
getOutputs()
Get all usable outputs.
TransactionProfiler $trxProfiler
Subclass ScopedCallback to avoid call_user_func_array(), which is slow.
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
profileOut( $functionname)
profileIn( $functionname)
close()
Close opened profiling sections.
Profiler base class that defines the interface and some trivial functionality.
when a variable name is used in a it is silently declared as a new masking the global
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
__construct(array $params)
bool $templated
Whether MediaWiki is in a SkinTemplate output context.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
setContext( $context)
Sets the context for this Profiler.
logData()
Log the data to some store or even the page output.
static getMain()
Static methods.
getContext()
Gets the context for this Profiler.
Interface for objects which can provide a MediaWiki context on request.
getFunctionStats()
Get the aggregated inclusive profiling data for each method.
logDataPageOutputOnly()
Output current data to the page output if configured to do so.
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.
scopedProfileOut(SectionProfileCallback &$section=null)
the array() calling protocol came about after MediaWiki 1.4rc1.