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 ) {
76 $inSample = mt_rand( 0,
$params[
'sampling'] - 1 ) === 0;
78 if ( PHP_SAPI ===
'cli' || PHP_SAPI ===
'phpdbg' || !$inSample ) {
82 if ( !is_array(
$params[
'output'] ) ) {
99 if ( self::$instance && !( self::$instance instanceof
ProfilerStub ) ) {
100 throw new MWException(
'Could not replace non-stub profiler instance.' );
102 self::$instance = $profiler;
110 $this->profileID = $id;
117 if ( $this->profileID ===
false ) {
141 if ( $this->context ) {
144 wfDebug( __METHOD__ .
" called and \$context is null. " .
145 "Return RequestContext::getMain(); for sanity\n" );
186 abstract public function close();
197 foreach ( $this->params[
'output']
as $outputType ) {
201 $outputClass = strpos( $outputType,
'ProfilerOutput' ) ===
false
202 ?
'ProfilerOutput' . ucfirst( $outputType )
204 if ( !class_exists( $outputClass ) ) {
205 throw new MWException(
"'$outputType' is an invalid output type" );
207 $outputInstance =
new $outputClass( $this, $this->params );
208 if ( $outputInstance->canUse() ) {
209 $outputs[] = $outputInstance;
223 $timeElapsed =
$request->getElapsedTime();
224 $timeElapsedThreshold = $this->params[
'threshold'];
225 if ( $timeElapsed <= $timeElapsedThreshold ) {
231 if ( !$output->logsToOutput() ) {
253 if ( $output->logsToOutput() ) {
274 if ( preg_match(
'#^content-type: (\w+/\w+);?#i',
$header, $m ) ) {
287 $this->templated =
$t;
$wgProfileLimit
Only record profiling info for pages that took longer than this.
getTemplated()
Was this call as templated or not.
static getCurrentWikiDbDomain()
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
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.
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)
$wgProfiler
Profiler configuration.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
profileIn( $functionname)
close()
Close opened profiling sections.
Profiler base class that defines the interface and some trivial functionality.
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
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))
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
setContext( $context)
Sets the context for this Profiler.
logData()
Log the data to the backing store for all ProfilerOutput instances that have one.
static getMain()
Get the RequestContext object associated with the main request.
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()
Log the data to the script/request output for all ProfilerOutput instances that 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.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
scopedProfileOut(SectionProfileCallback &$section=null)