math conversion after upgrading, obtain the Math extension from SVN or from
http://www.mediawiki.org/wiki/Extension:Math and add to LocalSettings.php:
require_once "$IP/extensions/Math/Math.php";
+* $wgProfiler is now a configuration array, see StartProfiler.sample for details
+* $wgProfiling has been removed
=== New features in 1.18 ===
* (bug 8130) Query pages should limit to content namespaces, not just main
* To use a profiler, copy this file to StartProfiler.php,
* delete the PHP line above, and add something like this:
*
- * require_once( dirname(__FILE__).'/includes/Profiler.php' );
- * $wgProfiler = new Profiler;
+ * $wgProfiler['class'] = 'Profiler';
*
* Or for a sampling profiler:
* if ( !mt_rand( 0, 100 ) ) {
- * require_once( dirname(__FILE__).'/includes/Profiler.php' );
- * $wgProfiler = new Profiler;
+ * $wgProfiler['class'] = 'Profiler';
* } else {
- * require_once( dirname(__FILE__).'/includes/ProfilerStub.php' );
+ * $wgProfiler['class'] = 'ProfilerStub';
* }
*
* Configuration of the profiler output can be done in LocalSettings.php
# Get MWInit class
require_once( "$IP/includes/Init.php" );
+ # Start the autoloader, so that extensions can derive classes from core files
+ require_once( "$IP/includes/AutoLoader.php" );
+
# Start profiler
# FIXME: rewrite wfProfileIn/wfProfileOut so that they can work in compiled mode
+ require_once( "$IP/includes/profiler/Profiler.php" );
if ( file_exists( "$IP/StartProfiler.php" ) ) {
require_once( "$IP/StartProfiler.php" );
- } else {
- require_once( "$IP/includes/profiler/ProfilerStub.php" );
}
# Load up some global defines.
require_once( "$IP/includes/Defines.php" );
-
- # Start the autoloader, so that extensions can derive classes from core files
- require_once( "$IP/includes/AutoLoader.php" );
}
wfProfileIn( 'WebStart.php-conf' );
* This file is only included if profiling is enabled
*/
-/** backward compatibility */
-$wgProfiling = true;
+/**
+ * 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 ) {
- global $wgProfiler;
- $wgProfiler->profileIn( $functionname );
+ Profiler::instance()->profileIn( $functionname );
}
/**
* @param $functionname String: name of the function we have profiled
*/
function wfProfileOut( $functionname = 'missing' ) {
- global $wgProfiler;
- $wgProfiler->profileOut( $functionname );
+ Profiler::instance()->profileOut( $functionname );
}
/**
* Returns a profiling output to be stored in debug file
*/
function wfGetProfilingOutput() {
- global $wgProfiler;
- return $wgProfiler->getOutput();
+ Profiler::instance()->getOutput();
}
/**
* Close opened profiling sections
*/
function wfProfileClose() {
- global $wgProfiler;
- $wgProfiler->close();
+ Profiler::instance()->close();
}
if (!function_exists('memory_get_usage')) {
var $mStack = array (), $mWorkStack = array (), $mCollated = array ();
var $mCalls = array (), $mTotals = array ();
var $mTemplated = false;
+ private static $__instance = null;
function __construct() {
// Push an entry for the pre-profile setup time onto the stack
}
}
+ /**
+ * Singleton
+ * @return Profiler
+ */
+ public static function instance() {
+ if( is_null( self::$__instance ) ) {
+ global $wgProfiler;
+ if( is_array( $wgProfiler ) ) {
+ $class = $wgProfiler['class'];
+ self::$__instance = new $class( $wgProfiler );
+ } elseif( $wgProfiler instanceof Profiler ) {
+ self::$__instance = $wgProfiler; // back-compat
+ } else {
+ throw new MWException( '$wgProfiler set to bogus value' );
+ }
+
+ }
+ return self::$__instance;
+ }
+
/**
* Called by wfProfieIn()
*
* @param $functionname String
*/
public function profileIn( $functionname ) {
- global $wgDebugFunctionEntry, $wgProfiling;
- if( !$wgProfiling ) return;
+ global $wgDebugFunctionEntry;
if( $wgDebugFunctionEntry ){
$this->debug( str_repeat( ' ', count( $this->mWorkStack ) ) . 'Entering ' . $functionname . "\n" );
}
* @param $functionname String
*/
public function profileOut($functionname) {
- global $wgDebugFunctionEntry, $wgProfiling;
- if( !$wgProfiling ) return;
+ global $wgDebugFunctionEntry;
$memory = memory_get_usage();
$time = $this->getTime();
* called by wfProfileClose()
*/
public function close() {
- global $wgProfiling;
-
- # Avoid infinite loop
- if( !$wgProfiling )
- return;
-
while( count( $this->mWorkStack ) ){
$this->profileOut( 'close' );
}
* @ingroup Profiler
*/
-if ( !class_exists( 'Profiler' ) ) {
- require_once( dirname( __FILE__ ) . '/Profiler.php' );
-}
-
/**
* Simple profiler base class.
* @todo document methods (?)
* @ingroup Profiler
*/
-if ( !class_exists( 'ProfilerSimple' ) ) {
- require_once( dirname( __FILE__ ) . '/ProfilerSimple.php' );
-}
-
/**
* The least sophisticated profiler output class possible, view your source! :)
*
- * Put the following 3 lines in StartProfiler.php:
+ * Put the following 2 lines in StartProfiler.php:
*
- * require_once( dirname( __FILE__ ) . '/includes/ProfilerSimpleText.php' );
- * $wgProfiler = new ProfilerSimpleText;
- * $wgProfiler->visible=true;
+ * $wgProfiler['class'] = 'ProfilerSimpleText';
+ * $wgProfiler['visible'] = true;
*
* @ingroup Profiler
*/
public $visible=false; /* Show as <PRE> or <!-- ? */
static private $out;
+ public function __construct( $profileConfig ) {
+ if( isset( $profileConfig['visible'] ) && $profileConfig['visible'] ) {
+ $this->visible = true;
+ }
+ parent::__construct();
+ }
+
function getFunctionReport() {
if($this->mTemplated) {
uasort($this->mCollated,array('self','sort'));
* @ingroup Profiler
*/
-if ( !class_exists( 'ProfilerSimple' ) ) {
- require_once( dirname( __FILE__ ) . '/ProfilerSimple.php' );
-}
-
/**
* Execution trace
* @todo document methods (?)
* @ingroup Profiler
*/
-if ( !class_exists( 'ProfilerSimple' ) ) {
- require_once( dirname( __FILE__ ) . '/ProfilerSimple.php' );
-}
-
/**
* ProfilerSimpleUDP class, that sends out messages for 'udpprofile' daemon
* (the one from mediawiki/trunk/udpprofile SVN )
* @file
* @ingroup Profiler
*/
-if ( !class_exists( 'Profiler' ) ) {
- require_once( dirname( __FILE__ ) . '/Profiler.php' );
-}
-
class ProfilerStub extends Profiler {
/**
public function getOutput() {}
public function close() {}
}
-
-/** backward compatibility */
-$wgProfiling = false;
-$wgProfiler = new ProfilerStub();
*/
public function finalSetup() {
global $wgCommandLineMode, $wgShowSQLErrors, $wgServer;
- global $wgProfiling, $wgDBadminuser, $wgDBadminpassword;
+ global $wgDBadminuser, $wgDBadminpassword;
global $wgDBuser, $wgDBpassword, $wgDBservers, $wgLBFactoryConf;
# Turn off output buffering again, it might have been turned on in the settings files
$wgShowSQLErrors = true;
@set_time_limit( 0 );
$this->adjustMemoryLimit();
-
- $wgProfiling = false; // only for Profiler.php mode; avoids OOM errors
}
/**
require_once( "$IP/includes/Init.php" );
}
-# Setup the profiler
-global $IP;
-if ( !defined( 'MW_COMPILED' ) && file_exists( "$IP/StartProfiler.php" ) ) {
- require_once( "$IP/StartProfiler.php" );
-} else {
- require_once( MWInit::compiledPath( 'includes/profiler/ProfilerStub.php' ) );
-}
+# Stub the profiler
+require_once( MWInit::compiledPath( 'includes/profiler/Profiler.php' ) );
// Some other requires
if ( !defined( 'MW_COMPILED' ) ) {