wiki.techinc.nl/includes/profiler/ProfilerStub.php
Alexandre Emsenhuber 21e53d3590 * Added Profiler::isStub() to check if we are using a stub profiler, instead of checking whether $wgProfiler is set
* Replaced wfProfileClose() and wfGetProfilingOutput() by direct calls to the Profiler instance and removed them, no uses in extensions
* Also removed useless params from Profiler::getOutput() call in wfLogProfilingData()
* Only generate profiling output if it'll be used; introduced Profiler::logData() that saves profiling data (database, udp, ...) to separate it from output generation
* Removed unused Profiler::getCaller(), not used at all, and we have wfGetCaller() that does the same thing
2011-04-21 16:31:02 +00:00

61 lines
1.1 KiB
PHP

<?php
/**
* Stub profiling functions
* @file
* @ingroup Profiler
*/
class ProfilerStub extends Profiler {
/**
* is setproctitle function available?
* @var bool
*/
private $haveProctitle;
private $hackWhere = array();
/**
* Constructor. Check for proctitle.
*/
public function __construct() {
$this->haveProctitle = function_exists( 'setproctitle' );
}
public function isStub() {
return true;
}
/**
* Begin profiling of a function
* @param $fn string
*/
public function profileIn( $fn ) {
global $wgDBname;
if( $this->haveProctitle ){
$this->hackWhere[] = $fn;
setproctitle( $fn . " [$wgDBname]" );
}
}
/**
* Stop profiling of a function
* @param $fn string
*/
public function profileOut( $fn ) {
global $wgDBname;
if( !$this->haveProctitle ) {
return;
}
if( count( $this->hackWhere ) ) {
array_pop( $this->hackWhere );
}
if( count( $this->hackWhere ) ) {
setproctitle( $this->hackWhere[count( $this->hackWhere )-1] . " [$wgDBname]" );
}
}
/**
* Does nothing, just for compatibility
*/
public function getOutput() {}
public function close() {}
}