# Start the autoloader, so that extensions can derive classes from core files
require_once( "$IP/includes/AutoLoader.php" );
- # Start profiler
- # @todo FIXME: Rewrite wfProfileIn/wfProfileOut so that they can work in compiled mode
+ # Load the profiler
require_once( "$IP/includes/profiler/Profiler.php" );
- if ( file_exists( "$IP/StartProfiler.php" ) ) {
- require_once( "$IP/StartProfiler.php" );
- }
# Load up some global defines.
require_once( "$IP/includes/Defines.php" );
}
+# Start the profiler
+$wgProfiler = array();
+if ( file_exists( "$IP/StartProfiler.php" ) ) {
+ require( "$IP/StartProfiler.php" );
+}
+
wfProfileIn( 'WebStart.php-conf' );
# Load default settings
* This file is only included if profiling is enabled
*/
-/**
- * Default profiling configuration. Permitted keys are:
- * class : Name of Profiler or subclass to use for profiling
- * visible : Whether to output the profile info [ProfilerSimpleText only]
- */
-$wgProfiler = array(
- 'class' => 'ProfilerStub',
-);
-
/**
* Begin profiling of a function
* @param $functionname String: name of the function we will profile
*/
function wfProfileIn( $functionname ) {
- Profiler::instance()->profileIn( $functionname );
+ global $wgProfiler;
+ if ( isset( $wgProfiler['class'] ) ) {
+ Profiler::instance()->profileIn( $functionname );
+ }
}
/**
* @param $functionname String: name of the function we have profiled
*/
function wfProfileOut( $functionname = 'missing' ) {
- Profiler::instance()->profileOut( $functionname );
+ global $wgProfiler;
+ if ( isset( $wgProfiler['class'] ) ) {
+ Profiler::instance()->profileOut( $functionname );
+ }
}
/**
var $mStack = array (), $mWorkStack = array (), $mCollated = array ();
var $mCalls = array (), $mTotals = array ();
var $mTemplated = false;
+ var $mTimeMetric = 'wall';
private $mCollateDone = false;
protected $mProfileID = false;
private static $__instance = null;
- function __construct() {
+ function __construct( $params ) {
// Push an entry for the pre-profile setup time onto the stack
global $wgRequestTime;
if ( !empty( $wgRequestTime ) ) {
} else {
$this->profileIn( '-total' );
}
+ if ( isset( $params['timeMetric'] ) ) {
+ $this->mTimeMetric = $params['timeMetric'];
+ }
}
/**
if( is_null( self::$__instance ) ) {
global $wgProfiler;
if( is_array( $wgProfiler ) ) {
- $class = $wgProfiler['class'];
+ $class = isset( $wgProfiler['class'] ) ? $wgProfiler['class'] : 'ProfilerStub';
self::$__instance = new $class( $wgProfiler );
} elseif( $wgProfiler instanceof Profiler ) {
self::$__instance = $wgProfiler; // back-compat
} else {
self::$__instance = new ProfilerStub;
}
-
}
return self::$__instance;
}
}
function getTime() {
- return microtime(true);
- #return $this->getUserTime();
+ if ( $this->mTimeMetric === 'user' ) {
+ return $this->getUserTime();
+ } else {
+ return microtime(true);
+ }
}
function getUserTime() {
* @param $s String to output
*/
function debug( $s ) {
- if( function_exists( 'wfDebug' ) ) {
+ if( defined( 'MW_COMPILED' ) || function_exists( 'wfDebug' ) ) {
wfDebug( $s );
}
}
* @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 profileIn( $fn ) {}
+ public function profileOut( $fn ) {}
public function getOutput() {}
public function close() {}
}