BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
SectionProfiler Class Reference

Public Member Functions

 __construct (array $params=[])
 
 scopedProfileIn ($section)
 
 scopedProfileOut (ScopedCallback &$section)
 
 getFunctionStats ()
 
 reset ()
 
 profileInInternal ($functionname)
 
 profileOutInternal ($functionname)
 
 getCallTreeReport ()
 

Protected Member Functions

 getZeroEntry ()
 
 getErrorEntry ()
 
 updateEntry ($name, $elapsedCpu, $elapsedReal, $memChange)
 
 remapCallTree (array $stack)
 
 getCallTreeLine ($entry)
 
 collateData ()
 
 calculateOverhead ($profileCount)
 
 calltreeCount ($stack, $start)
 
 getTime ($metric= 'wall')
 
 debug ($s)
 
 debugGroup ($group, $s)
 

Protected Attributes

 $start
 
 $end
 
 $stack = []
 
 $workStack = []
 
 $collated = []
 
 $collateDone = false
 
 $collateOnly = true
 
 $errorEntry
 
 $profileOutCallback
 

Detailed Description

Custom PHP profiler for parser/DB type section names that xhprof/xdebug can't handle

Since
1.25

Constructor & Destructor Documentation

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

Member Function Documentation

SectionProfiler::calculateOverhead (   $profileCount)
protected

Dummy calls to calculate profiling overhead

Parameters
int$profileCount
SectionProfiler::calltreeCount (   $stack,
  $start 
)
protected

Counts the number of profiled function calls sitting under the given point in the call graph. Not the most efficient algo.

Parameters
array$stack
int$start
Returns
int
SectionProfiler::collateData ( )
protected

Populate collated data

SectionProfiler::debug (   $s)
protected

Add an entry in the debug log file

Parameters
string$sString to output
SectionProfiler::debugGroup (   $group,
  $s 
)
protected

Add an entry in the debug log group

Parameters
string$groupGroup to send the message to
string$sString to output
SectionProfiler::getCallTreeLine (   $entry)
protected

Callback to get a formatted line for the call tree

Parameters
array$entry
Returns
string
SectionProfiler::getCallTreeReport ( )

Returns a tree of function calls with their real times

Returns
string
Exceptions
Exception
SectionProfiler::getErrorEntry ( )
protected
Returns
array Initial collation entry for errors
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)
SectionProfiler::getTime (   $metric = 'wall')
protected

Get the initial time of the request, based on getrusage()

Parameters
string | bool$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
SectionProfiler::getZeroEntry ( )
protected
Returns
array Initial collation entry
SectionProfiler::profileInInternal (   $functionname)

This method should not be called outside SectionProfiler

Parameters
string$functionname
SectionProfiler::profileOutInternal (   $functionname)

This method should not be called outside SectionProfiler

Parameters
string$functionname
SectionProfiler::remapCallTree ( array  $stack)
protected

Recursive function the format the current profiling array into a tree

Parameters
array$stackProfiling array
Returns
array
SectionProfiler::reset ( )

Clear all of the profiling data for another run

SectionProfiler::scopedProfileIn (   $section)
Parameters
string$section
Returns
ScopedCallback
SectionProfiler::scopedProfileOut ( ScopedCallback $section)
Parameters
ScopedCallback$section
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

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