MediaWiki  REL1_22
Profiler Class Reference
Inheritance diagram for Profiler:

List of all members.

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

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

Static Public Attributes

static $__instance = null

Protected Member Functions

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

Static Protected Member Functions

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

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

Profiler::__construct ( params)

Reimplemented in ProfilerSimpleText.

Definition at line 112 of file Profiler.php.

References $params, and addInitialStack().


Member Function Documentation

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().

static Profiler::calculateOverhead ( profileCount) [static, protected]

Dummy calls to wfProfileIn/wfProfileOut to calculate its overhead.

Definition at line 614 of file Profiler.php.

References wfProfileIn(), and wfProfileOut().

Referenced by collateData().

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:
private

Definition at line 632 of file Profiler.php.

References $count.

Referenced by collateData().

Close opened profiling sections.

Reimplemented in ProfilerStub.

Definition at line 251 of file Profiler.php.

References profileOut().

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

Profiler::collateData ( ) [protected]

Definition at line 497 of file Profiler.php.

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

Referenced by getFunctionReport(), and logData().

Profiler::debug ( s)

Add an entry in the debug log file.

Parameters:
string$sto output

Definition at line 717 of file Profiler.php.

References $s, and wfDebug().

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

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

Returns:
string

Definition at line 367 of file Profiler.php.

References array(), and remapCallTree().

Referenced by getOutput().

Callback to get a formatted line for the call tree.

Returns:
string

Definition at line 416 of file Profiler.php.

References $fname, and list.

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 728 of file Profiler.php.

References as.

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

Get the function name of the current profiling section.

Returns:

Reimplemented in ProfilerStub.

Definition at line 707 of file Profiler.php.

Returns a list of profiled functions.

Returns:
string

Reimplemented in ProfilerSimple.

Definition at line 578 of file Profiler.php.

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

Referenced by getOutput().

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 469 of file Profiler.php.

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

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

Returns a profiling output to be stored in debug file.

Returns:
String

Reimplemented in ProfilerStub.

Definition at line 348 of file Profiler.php.

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

Definition at line 177 of file Profiler.php.

References wfWikiID().

Referenced by ProfilerSimpleUDP\logData().

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 436 of file Profiler.php.

References $time.

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

Return whether this profiler stores data.

See also:
Profiler::logData()
Returns:
Boolean

Reimplemented in ProfilerSimple, ProfilerStub, and ProfilerSimpleUDP.

Definition at line 169 of file Profiler.php.

Return whether this a stub profiler.

Returns:
Boolean

Reimplemented in ProfilerStub.

Definition at line 159 of file Profiler.php.

Log the whole profiling data into the database.

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

Definition at line 644 of file Profiler.php.

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

Profiler::profileIn ( functionname)

Called by wfProfieIn()

Parameters:
$functionnameString

Reimplemented in ProfilerSimple, ProfilerStub, and ProfilerSimpleTrace.

Definition at line 204 of file Profiler.php.

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

Referenced by addInitialStack().

Profiler::profileOut ( functionname)

Called by wfProfieOut()

Parameters:
$functionnameString

Reimplemented in ProfilerSimple, ProfilerSimpleTrace, and ProfilerStub.

Definition at line 218 of file Profiler.php.

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

Referenced by close().

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

Parameters:
array$stackprofiling array
Returns:
array

Definition at line 377 of file Profiler.php.

References $output, array(), and as.

Referenced by getCallTree().

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().

Definition at line 173 of file Profiler.php.

Mark this call as templated or not.

Parameters:
$tBoolean

Definition at line 339 of file Profiler.php.

References $t.

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 265 of file Profiler.php.

References $name, and array().

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 309 of file Profiler.php.

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

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 281 of file Profiler.php.

References $name, array(), and as.

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


Member Data Documentation

Profiler::$__instance = null [static]
Profiler::$mCalls = array()

Definition at line 99 of file Profiler.php.

Profiler::$mCollated = array()

Definition at line 98 of file Profiler.php.

Profiler::$mCollateDone = false

Definition at line 101 of file Profiler.php.

Profiler::$mDBLockThreshold = 5.0 [protected]

Definition at line 103 of file Profiler.php.

Profiler::$mDBTrxHoldingLocks = array() [protected]

Definition at line 105 of file Profiler.php.

Profiler::$mDBTrxMethodTimes = array() [protected]

Definition at line 107 of file Profiler.php.

Profiler::$mProfileID = false [protected]

Definition at line 101 of file Profiler.php.

Profiler::$mStack = array() [protected]

Definition at line 98 of file Profiler.php.

Profiler::$mTemplated = false

Definition at line 101 of file Profiler.php.

Profiler::$mTimeMetric = 'wall' [protected]

Definition at line 100 of file Profiler.php.

Profiler::$mTotals = array()

Definition at line 99 of file Profiler.php.

Profiler::$mWorkStack = array()

Definition at line 98 of file Profiler.php.


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