MediaWiki REL1_28
|
Custom PHP profiler for parser/DB type section names that xhprof/xdebug can't handle. More...
Public Member Functions | |
__construct (array $params=[]) | |
getCallTreeReport () | |
Returns a tree of function calls with their real times. | |
getFunctionStats () | |
Get the aggregated inclusive profiling data for each method. | |
profileInInternal ( $functionname) | |
This method should not be called outside SectionProfiler. | |
profileOutInternal ( $functionname) | |
This method should not be called outside SectionProfiler. | |
reset () | |
Clear all of the profiling data for another run. | |
scopedProfileIn ( $section) | |
scopedProfileOut (ScopedCallback &$section) | |
Protected Member Functions | |
calculateOverhead ( $profileCount) | |
Dummy calls to calculate profiling overhead. | |
calltreeCount ( $stack, $start) | |
Counts the number of profiled function calls sitting under the given point in the call graph. | |
collateData () | |
Populate collated data. | |
debug ( $s) | |
Add an entry in the debug log file. | |
debugGroup ( $group, $s) | |
Add an entry in the debug log group. | |
getCallTreeLine ( $entry) | |
Callback to get a formatted line for the call tree. | |
getErrorEntry () | |
getTime ( $metric='wall') | |
Get the initial time of the request, based on getrusage() | |
getZeroEntry () | |
remapCallTree (array $stack) | |
Recursive function the format the current profiling array into a tree. | |
updateEntry ( $name, $elapsedCpu, $elapsedReal, $memChange) | |
Update the collation entry for a given method name. | |
Protected Attributes | |
array | $collated = [] |
Map of (function name => aggregate data array) | |
bool | $collateDone = false |
bool | $collateOnly = true |
Whether to collect the full stack trace or just aggregates. | |
array | $end |
Map of (mem,real,cpu) | |
array | $errorEntry |
Cache of a standard broken collation entry. | |
array | $stack = [] |
List of resolved profile calls with start/end data. | |
array | $start |
Map of (mem,real,cpu) | |
array | $workStack = [] |
Queue of open profile calls with start data. | |
Custom PHP profiler for parser/DB type section names that xhprof/xdebug can't handle.
Definition at line 31 of file SectionProfiler.php.
SectionProfiler::__construct | ( | array | $params = [] | ) |
array | $params |
Definition at line 54 of file SectionProfiler.php.
References $params, and getErrorEntry().
|
protected |
Dummy calls to calculate profiling overhead.
int | $profileCount |
Definition at line 423 of file SectionProfiler.php.
References profileInInternal(), and profileOutInternal().
Referenced by collateData().
|
protected |
Counts the number of profiled function calls sitting under the given point in the call graph.
Not the most efficient algo.
array | $stack | |
int | $start |
Definition at line 440 of file SectionProfiler.php.
References $count, $stack, and $start.
Referenced by collateData().
|
protected |
Populate collated data.
Definition at line 347 of file SectionProfiler.php.
References $end, $fname, as, calculateOverhead(), calltreeCount(), profileOutInternal(), and updateEntry().
Referenced by getFunctionStats().
|
protected |
Add an entry in the debug log file.
string | $s | String to output |
Definition at line 482 of file SectionProfiler.php.
|
protected |
Add an entry in the debug log group.
string | $group | Group to send the message to |
string | $s | String to output |
Definition at line 494 of file SectionProfiler.php.
References $s, and wfDebugLog().
Referenced by profileOutInternal().
|
protected |
Callback to get a formatted line for the call tree.
array | $entry |
Definition at line 333 of file SectionProfiler.php.
SectionProfiler::getCallTreeReport | ( | ) |
Returns a tree of function calls with their real times.
Exception |
Definition at line 278 of file SectionProfiler.php.
References remapCallTree().
|
protected |
Definition at line 165 of file SectionProfiler.php.
References getZeroEntry().
Referenced by __construct().
SectionProfiler::getFunctionStats | ( | ) |
Get the aggregated inclusive profiling data for each method.
The percent time for each time is based on the current "total" time used is based on all methods so far. This method can therefore be called several times in between several profiling calls without the delays in usage of the profiler skewing the results. A "-total" entry is always included in the results.
Definition at line 97 of file SectionProfiler.php.
References $fname, as, and collateData().
|
protected |
Get the initial time of the request, based on getrusage()
string | bool | $metric | Metric to use, with the following possibilities:
|
Definition at line 459 of file SectionProfiler.php.
References $time, and wfGetRusage().
Referenced by profileInInternal(), and profileOutInternal().
|
protected |
Definition at line 151 of file SectionProfiler.php.
Referenced by getErrorEntry(), and updateEntry().
SectionProfiler::profileInInternal | ( | $functionname | ) |
This method should not be called outside SectionProfiler.
string | $functionname |
Definition at line 198 of file SectionProfiler.php.
References getTime().
Referenced by calculateOverhead(), and scopedProfileIn().
SectionProfiler::profileOutInternal | ( | $functionname | ) |
This method should not be called outside SectionProfiler.
string | $functionname |
Definition at line 226 of file SectionProfiler.php.
References $errorEntry, debugGroup(), getTime(), list, and updateEntry().
Referenced by calculateOverhead(), and collateData().
|
protected |
Recursive function the format the current profiling array into a tree.
array | $stack | Profiling array |
Definition at line 293 of file SectionProfiler.php.
References $output, $stack, as, and remapCallTree().
Referenced by getCallTreeReport(), and remapCallTree().
SectionProfiler::reset | ( | ) |
Clear all of the profiling data for another run.
Definition at line 139 of file SectionProfiler.php.
SectionProfiler::scopedProfileIn | ( | $section | ) |
string | $section |
Definition at line 63 of file SectionProfiler.php.
References $section, and profileInInternal().
SectionProfiler::scopedProfileOut | ( | ScopedCallback & | $section | ) |
ScopedCallback | $section |
Definition at line 72 of file SectionProfiler.php.
References $section.
|
protected |
Update the collation entry for a given method name.
string | $name | |
float | $elapsedCpu | |
float | $elapsedReal | |
int | $memChange |
Definition at line 179 of file SectionProfiler.php.
References $name, and getZeroEntry().
Referenced by collateData(), and profileOutInternal().
|
protected |
Map of (function name => aggregate data array)
Definition at line 42 of file SectionProfiler.php.
|
protected |
Definition at line 44 of file SectionProfiler.php.
|
protected |
Whether to collect the full stack trace or just aggregates.
Definition at line 47 of file SectionProfiler.php.
|
protected |
Map of (mem,real,cpu)
Definition at line 35 of file SectionProfiler.php.
Referenced by collateData().
|
protected |
Cache of a standard broken collation entry.
Definition at line 49 of file SectionProfiler.php.
Referenced by profileOutInternal().
|
protected |
List of resolved profile calls with start/end data.
Definition at line 37 of file SectionProfiler.php.
Referenced by calltreeCount(), and remapCallTree().
|
protected |
Map of (mem,real,cpu)
Definition at line 33 of file SectionProfiler.php.
Referenced by calltreeCount().
|
protected |
Queue of open profile calls with start data.
Definition at line 39 of file SectionProfiler.php.