MediaWiki master
MediaWiki\Profiler\SectionProfiler Class Reference

Arbitrary section name based PHP profiling. More...

Public Member Functions

 __construct (array $params=[])
 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 (?SectionProfileCallback &$section)

Protected Member Functions

 collateData ()
 Populate collated data.
 getErrorEntry ()
 getZeroEntry ()
 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
array null $end
 Map of (mem,real,cpu).
array $errorEntry
 Cache of a standard broken collation entry.
LoggerInterface $logger
array[] $stack = []
 List of resolved profile calls with start/end data.
array null $start
 Map of (mem,real,cpu).
array $workStack = []
 Queue of open profile calls with start data.

Detailed Description

Arbitrary section name based PHP profiling.

This custom profiler can track code execution that doesn't cleanly map to a function call and thus can't be handled by ProfilerXhprof or ProfilerExcimer. For example, parser invocations or DB queries.

Since
1.25

Definition at line 23 of file SectionProfiler.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Profiler\SectionProfiler::__construct ( array $params = [])
Parameters
array$params

Definition at line 45 of file SectionProfiler.php.

References getErrorEntry().

Member Function Documentation

◆ collateData()

MediaWiki\Profiler\SectionProfiler::collateData ( )
protected

Populate collated data.

Definition at line 256 of file SectionProfiler.php.

References profileOutInternal().

Referenced by getFunctionStats().

◆ getErrorEntry()

MediaWiki\Profiler\SectionProfiler::getErrorEntry ( )
protected
Returns
array Initial collation entry for errors

Definition at line 159 of file SectionProfiler.php.

References getZeroEntry().

Referenced by __construct().

◆ getFunctionStats()

MediaWiki\Profiler\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.

Returns
array[] List of method entries arrays, each having:
  • name : method name
  • calls : the number of invoking calls
  • real : real time elapsed (ms)
  • real : percent real time
  • cpu : real time elapsed (ms)
  • cpu : percent real time
  • memory : memory used (bytes)
  • memory : percent memory used
  • min_real : min real time in a call (ms)
  • max_real : max real time in a call (ms)

Definition at line 85 of file SectionProfiler.php.

References collateData().

◆ getZeroEntry()

MediaWiki\Profiler\SectionProfiler::getZeroEntry ( )
protected
Returns
array Initial collation entry

Definition at line 145 of file SectionProfiler.php.

Referenced by getErrorEntry(), and updateEntry().

◆ profileInInternal()

MediaWiki\Profiler\SectionProfiler::profileInInternal ( $functionname)

This method should not be called outside SectionProfiler.

Parameters
string$functionname

Definition at line 192 of file SectionProfiler.php.

Referenced by scopedProfileIn().

◆ profileOutInternal()

MediaWiki\Profiler\SectionProfiler::profileOutInternal ( $functionname)

This method should not be called outside SectionProfiler.

Parameters
string$functionname

Definition at line 218 of file SectionProfiler.php.

References updateEntry().

Referenced by collateData().

◆ reset()

MediaWiki\Profiler\SectionProfiler::reset ( )

Clear all of the profiling data for another run.

Definition at line 133 of file SectionProfiler.php.

◆ scopedProfileIn()

MediaWiki\Profiler\SectionProfiler::scopedProfileIn ( $section)
Parameters
string$section

Definition at line 54 of file SectionProfiler.php.

References profileInInternal().

◆ scopedProfileOut()

MediaWiki\Profiler\SectionProfiler::scopedProfileOut ( ?SectionProfileCallback & $section)

Definition at line 60 of file SectionProfiler.php.

◆ updateEntry()

MediaWiki\Profiler\SectionProfiler::updateEntry ( $name,
$elapsedCpu,
$elapsedReal,
$memChange )
protected

Update the collation entry for a given method name.

Parameters
string$name
float$elapsedCpu
float$elapsedReal
int$memChange

Definition at line 173 of file SectionProfiler.php.

References getZeroEntry().

Referenced by profileOutInternal().

Member Data Documentation

◆ $collated

array [] MediaWiki\Profiler\SectionProfiler::$collated = []
protected

Map of (function name => aggregate data array).

Definition at line 33 of file SectionProfiler.php.

◆ $collateDone

bool MediaWiki\Profiler\SectionProfiler::$collateDone = false
protected

Definition at line 35 of file SectionProfiler.php.

◆ $end

array null MediaWiki\Profiler\SectionProfiler::$end
protected

Map of (mem,real,cpu).

Definition at line 27 of file SectionProfiler.php.

◆ $errorEntry

array MediaWiki\Profiler\SectionProfiler::$errorEntry
protected

Cache of a standard broken collation entry.

Definition at line 38 of file SectionProfiler.php.

◆ $logger

LoggerInterface MediaWiki\Profiler\SectionProfiler::$logger
protected

Definition at line 40 of file SectionProfiler.php.

◆ $stack

array [] MediaWiki\Profiler\SectionProfiler::$stack = []
protected

List of resolved profile calls with start/end data.

Definition at line 29 of file SectionProfiler.php.

◆ $start

array null MediaWiki\Profiler\SectionProfiler::$start
protected

Map of (mem,real,cpu).

Definition at line 25 of file SectionProfiler.php.

◆ $workStack

array MediaWiki\Profiler\SectionProfiler::$workStack = []
protected

Queue of open profile calls with start data.

Definition at line 31 of file SectionProfiler.php.


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