MediaWiki  1.23.2
Profiler Class Reference
Inheritance diagram for Profiler:

Public Member Functions

 __construct ( $params)
 
 calltreeCount ( $stack, $start)
 Counts the number of profiled function calls sitting under the given point in the call graph. More...
 
 close ()
 Close opened profiling sections. More...
 
 debug ( $s)
 Add an entry in the debug log file. More...
 
 debugGroup ( $group, $s)
 Add an entry in the debug log group. More...
 
 getCallTree ()
 Returns a tree of function call instead of a list of functions. More...
 
 getCallTreeLine ( $entry)
 Callback to get a formatted line for the call tree. More...
 
 getCurrentSection ()
 Get the function name of the current profiling section. More...
 
 getFunctionReport ()
 Returns a list of profiled functions. More...
 
 getOutput ()
 Returns a profiling output to be stored in debug file. More...
 
 getProfileID ()
 
 getRawData ()
 
 getTime ( $metric=false)
 Get the initial time of the request, based either on $wgRequestTime or $wgRUstart. More...
 
 isPersistent ()
 Return whether this profiler stores data. More...
 
 isStub ()
 Return whether this a stub profiler. More...
 
 logData ()
 Log the whole profiling data into the database. More...
 
 profileIn ( $functionname)
 Called by wfProfieIn() More...
 
 profileOut ( $functionname)
 Called by wfProfieOut() More...
 
 remapCallTree ( $stack)
 Recursive function the format the current profiling array into a tree. More...
 
 setProfileID ( $id)
 
 setTemplated ( $t)
 Mark this call as templated or not. More...
 
 transactionWritingIn ( $server, $db)
 Mark a DB as in a transaction with one or more writes pending. More...
 
 transactionWritingOut ( $server, $db)
 Mark a DB as no longer in a transaction. More...
 

Static Public Member Functions

static instance ()
 Singleton. More...
 
static setInstance (Profiler $p)
 Set the profiler to a specific profiler instance. More...
 

Public Attributes

 $mCalls = array()
 
 $mCollated = array()
 
 $mCollateDone = false
 
 $mPeriods = array()
 
 $mTemplated = false
 
 $mTotals = array()
 
 $mWorkStack = array()
 

Static Public Attributes

static $__instance = null
 

Protected Member Functions

 addInitialStack ()
 Add the inital item in the stack. More...
 
 collateData ()
 
 getContentType ()
 Get the content type sent out to the client. More...
 
 getInitialTime ( $metric=false)
 Get the initial time of the request, based either on $wgRequestTime or $wgRUstart. More...
 
 updateTrxProfiling ( $method, $realtime)
 Register the name and time of a method for slow DB trx detection. More...
 

Static Protected Member Functions

static calculateOverhead ( $profileCount)
 Dummy calls to wfProfileIn/wfProfileOut to calculate its overhead. More...
 

Protected Attributes

 $mDBLockThreshold = 5.0
 
 $mDBTrxHoldingLocks = array()
 
 $mDBTrxMethodTimes = array()
 
 $mProfileID = false
 
 $mStack = array()
 
 $mTimeMetric = 'wall'
 

Detailed Description

Todo:
document

Definition at line 97 of file Profiler.php.

Constructor & Destructor Documentation

◆ __construct()

Profiler::__construct (   $params)

Reimplemented in ProfilerSimpleText.

Definition at line 112 of file Profiler.php.

References $params, and addInitialStack().

Member Function Documentation

◆ addInitialStack()

Profiler::addInitialStack ( )
protected

Add the inital item in the stack.

Reimplemented in ProfilerSimple.

Definition at line 188 of file Profiler.php.

References array(), getInitialTime(), getTime(), and profileIn().

Referenced by __construct().

◆ calculateOverhead()

static Profiler::calculateOverhead (   $profileCount)
staticprotected

Dummy calls to wfProfileIn/wfProfileOut to calculate its overhead.

Definition at line 649 of file Profiler.php.

References wfProfileIn(), and wfProfileOut().

Referenced by collateData().

◆ calltreeCount()

Profiler::calltreeCount (   $stack,
  $start 
)

Counts the number of profiled function calls sitting under the given point in the call graph.

Not the most efficient algo.

Parameters
$stackArray:
$startInteger:
Returns
Integer
Access:\n private

Definition at line 667 of file Profiler.php.

References $count.

Referenced by collateData().

◆ close()

Profiler::close ( )

Close opened profiling sections.

Reimplemented in ProfilerStub.

Definition at line 253 of file Profiler.php.

References profileOut().

Referenced by collateData(), ProfilerSimpleUDP\logData(), ProfilerSimpleText\logData(), and ProfilerMwprof\logData().

◆ collateData()

Profiler::collateData ( )
protected

Definition at line 499 of file Profiler.php.

References $fname, array(), as, calculateOverhead(), calltreeCount(), and close().

Referenced by getFunctionReport(), getRawData(), and logData().

◆ debug()

Profiler::debug (   $s)

Add an entry in the debug log file.

Parameters
string$sto output

Definition at line 752 of file Profiler.php.

References $s, and wfDebug().

Referenced by ProfilerSimple\profileIn(), profileIn(), ProfilerSimpleTrace\profileOut(), ProfilerSimple\profileOut(), and profileOut().

◆ debugGroup()

Profiler::debugGroup (   $group,
  $s 
)

Add an entry in the debug log group.

Parameters
string$groupGroup to send the message to
string$sto output

Definition at line 764 of file Profiler.php.

References $s, and wfDebugLog().

Referenced by ProfilerMwprof\profileOut(), ProfilerSimple\profileOut(), profileOut(), and transactionWritingOut().

◆ getCallTree()

Profiler::getCallTree ( )

Returns a tree of function call instead of a list of functions.

Returns
string

Definition at line 369 of file Profiler.php.

References array(), and remapCallTree().

Referenced by getOutput().

◆ getCallTreeLine()

Profiler::getCallTreeLine (   $entry)

Callback to get a formatted line for the call tree.

Returns
string

Definition at line 418 of file Profiler.php.

References $fname, and list.

◆ getContentType()

Profiler::getContentType ( )
protected

Get the content type sent out to the client.

Used for profilers that output instead of store data.

Returns
string

Definition at line 775 of file Profiler.php.

References as.

Referenced by ProfilerSimpleText\logData(), and ProfilerSimpleTrace\logData().

◆ getCurrentSection()

Profiler::getCurrentSection ( )

Get the function name of the current profiling section.

Returns

Reimplemented in ProfilerStub.

Definition at line 742 of file Profiler.php.

◆ getFunctionReport()

Profiler::getFunctionReport ( )

Returns a list of profiled functions.

Returns
string

Reimplemented in ProfilerSimple, and ProfilerMwprof.

Definition at line 582 of file Profiler.php.

References $fname, $total, as, and collateData().

Referenced by getOutput().

◆ getInitialTime()

Profiler::getInitialTime (   $metric = false)
protected

Get the initial time of the request, based either on $wgRequestTime or $wgRUstart.

Will return null if not able to find data.

Parameters
string | false$metricmetric to use, with the following possibilities:
  • user: User CPU time (without system calls)
  • cpu: Total CPU time (user and system calls)
  • wall (or any other string): elapsed time
  • false (default): will fall back to default metric
Returns
float|null

Definition at line 471 of file Profiler.php.

References $mTimeMetric, $time, $wgRequestTime, and global.

Referenced by ProfilerSimple\addInitialStack(), and addInitialStack().

◆ getOutput()

Profiler::getOutput ( )

Returns a profiling output to be stored in debug file.

Returns
String

Reimplemented in ProfilerStub.

Definition at line 350 of file Profiler.php.

References getCallTree(), getFunctionReport(), and global.

◆ getProfileID()

Profiler::getProfileID ( )

Definition at line 177 of file Profiler.php.

References $mProfileID, and wfWikiID().

Referenced by ProfilerSimpleUDP\logData().

◆ getRawData()

Profiler::getRawData ( )
Returns
array

Reimplemented in ProfilerSimple, and ProfilerStub.

Definition at line 618 of file Profiler.php.

References $fname, $total, array(), as, and collateData().

◆ getTime()

Profiler::getTime (   $metric = false)

Get the initial time of the request, based either on $wgRequestTime or $wgRUstart.

Will return null if not able to find data.

Parameters
string | false$metricmetric to use, with the following possibilities:
  • user: User CPU time (without system calls)
  • cpu: Total CPU time (user and system calls)
  • wall (or any other string): elapsed time
  • false (default): will fall back to default metric
Returns
float|null

Definition at line 438 of file Profiler.php.

References $mTimeMetric, and $time.

Referenced by addInitialStack(), ProfilerMwprof\profileIn(), ProfilerSimple\profileIn(), profileIn(), ProfilerSimpleTrace\profileOut(), ProfilerMwprof\profileOut(), ProfilerSimple\profileOut(), and profileOut().

◆ instance()

◆ isPersistent()

Profiler::isPersistent ( )

Return whether this profiler stores data.

See also
Profiler::logData()
Returns
Boolean

Reimplemented in ProfilerSimple, ProfilerMwprof, ProfilerStub, and ProfilerSimpleUDP.

Definition at line 169 of file Profiler.php.

◆ isStub()

Profiler::isStub ( )

Return whether this a stub profiler.

Returns
Boolean

Reimplemented in ProfilerStub.

Definition at line 159 of file Profiler.php.

◆ logData()

Profiler::logData ( )

Log the whole profiling data into the database.

Reimplemented in ProfilerMwprof, ProfilerSimple, ProfilerSimpleTrace, ProfilerSimpleText, ProfilerStub, and ProfilerSimpleUDP.

Definition at line 679 of file Profiler.php.

References $e, $name, array(), as, collateData(), DB_MASTER, global, wfGetDB(), wfHostname(), and wfReadOnly().

◆ profileIn()

Profiler::profileIn (   $functionname)

Called by wfProfieIn()

Parameters
$functionnameString

Reimplemented in ProfilerMwprof, ProfilerSimple, ProfilerSimpleTrace, and ProfilerStub.

Definition at line 204 of file Profiler.php.

References array(), debug(), getTime(), and global.

Referenced by addInitialStack().

◆ profileOut()

Profiler::profileOut (   $functionname)

Called by wfProfieOut()

Parameters
$functionnameString

Reimplemented in ProfilerMwprof, ProfilerSimple, ProfilerSimpleTrace, and ProfilerStub.

Definition at line 218 of file Profiler.php.

References $time, array(), debug(), debugGroup(), getTime(), global, and updateTrxProfiling().

Referenced by close().

◆ remapCallTree()

Profiler::remapCallTree (   $stack)

Recursive function the format the current profiling array into a tree.

Parameters
array$stackprofiling array
Returns
array

Definition at line 379 of file Profiler.php.

References $output, array(), and as.

Referenced by getCallTree().

◆ setInstance()

static Profiler::setInstance ( Profiler  $p)
static

Set the profiler to a specific profiler instance.

Mostly for dumpHTML

Parameters
$pProfiler object

Definition at line 150 of file Profiler.php.

Referenced by TestFileOpPerformance\execute(), and Maintenance\finalSetup().

◆ setProfileID()

Profiler::setProfileID (   $id)

Definition at line 173 of file Profiler.php.

◆ setTemplated()

Profiler::setTemplated (   $t)

Mark this call as templated or not.

Parameters
$tBoolean

Definition at line 341 of file Profiler.php.

References $t.

◆ transactionWritingIn()

Profiler::transactionWritingIn (   $server,
  $db 
)

Mark a DB as in a transaction with one or more writes pending.

Note that there can be multiple connections to a single DB.

Parameters
string$serverDB server
string$dbDB name

Reimplemented in ProfilerStub.

Definition at line 267 of file Profiler.php.

References $name, and array().

◆ transactionWritingOut()

Profiler::transactionWritingOut (   $server,
  $db 
)

Mark a DB as no longer in a transaction.

This will check if locks are possibly held for longer than needed and log any affected transactions to a special DB log. Note that there can be multiple connections to a single DB.

Parameters
string$serverDB server
string$dbDB name

Reimplemented in ProfilerStub.

Definition at line 311 of file Profiler.php.

References $name, as, debugGroup(), and list.

◆ updateTrxProfiling()

Profiler::updateTrxProfiling (   $method,
  $realtime 
)
protected

Register the name and time of a method for slow DB trx detection.

Parameters
string$methodFunction name
float$realtimeWal time ellapsed

Definition at line 283 of file Profiler.php.

References $name, array(), and as.

Referenced by ProfilerSimpleTrace\profileOut(), ProfilerMwprof\profileOut(), ProfilerSimple\profileOut(), and profileOut().

Member Data Documentation

◆ $__instance

Profiler::$__instance = null
static

◆ $mCalls

Profiler::$mCalls = array()

Definition at line 99 of file Profiler.php.

◆ $mCollated

Profiler::$mCollated = array()

Definition at line 98 of file Profiler.php.

◆ $mCollateDone

Profiler::$mCollateDone = false

Definition at line 101 of file Profiler.php.

◆ $mDBLockThreshold

Profiler::$mDBLockThreshold = 5.0
protected

Definition at line 103 of file Profiler.php.

◆ $mDBTrxHoldingLocks

Profiler::$mDBTrxHoldingLocks = array()
protected

Definition at line 105 of file Profiler.php.

◆ $mDBTrxMethodTimes

Profiler::$mDBTrxMethodTimes = array()
protected

Definition at line 107 of file Profiler.php.

◆ $mPeriods

Profiler::$mPeriods = array()

Definition at line 99 of file Profiler.php.

◆ $mProfileID

Profiler::$mProfileID = false
protected

Definition at line 101 of file Profiler.php.

Referenced by getProfileID().

◆ $mStack

Profiler::$mStack = array()
protected

Definition at line 98 of file Profiler.php.

◆ $mTemplated

Profiler::$mTemplated = false

Definition at line 101 of file Profiler.php.

◆ $mTimeMetric

Profiler::$mTimeMetric = 'wall'
protected

Definition at line 100 of file Profiler.php.

Referenced by getInitialTime(), and getTime().

◆ $mTotals

Profiler::$mTotals = array()

Definition at line 99 of file Profiler.php.

◆ $mWorkStack

Profiler::$mWorkStack = array()

Definition at line 98 of file Profiler.php.


The documentation for this class was generated from the following file: