Add some more profiling points
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 19 Aug 2004 08:44:13 +0000 (08:44 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 19 Aug 2004 08:44:13 +0000 (08:44 +0000)
includes/MessageCache.php
includes/Parser.php

index 7ff3778..059af8d 100755 (executable)
@@ -16,6 +16,8 @@ class MessageCache
        var $mInitialised = false;
 
        function initialise( &$memCached, $useDB, $expiry, $memcPrefix ) {
+               $fname = "MessageCache::initialise";
+               wfProfileIn( $fname );
                $this->mUseCache = !is_null( $memCached );
                $this->mMemc = &$memCached;
                $this->mDisable = !$useDB;
@@ -24,10 +26,15 @@ class MessageCache
                $this->mMemcKey = "$memcPrefix:messages";
                $this->mKeys = false; # initialised on demand
                $this->mInitialised = true;
+               wfProfileIn( "$fname-parseropt" );
                $this->mParserOptions = ParserOptions::newFromUser( $u=NULL );
+               wfProfileIn( "$fname-parseropt" );
+               wfProfileOut( "$fname-parser" );
                $this->mParser = new Parser;
+               wfProfileOut( "$fname-parser" );
                
                $this->load();
+               wfProfileOut( $fname );
        }
 
        # Loads messages either from memcached or the database, if not disabled
@@ -40,11 +47,14 @@ class MessageCache
                        wfDebug( "MessageCache::load(): disabled\n" );
                        return true;
                }
-               
+               $fname = "MessageCache::load";
+               wfProfileIn( $fname );
                $success = true;
                
                if ( $this->mUseCache ) {
+                       wfProfileIn( "$fname-fromcache" );
                        $this->mCache = $this->mMemc->get( $this->mMemcKey );
+                       wfProfileOut( "$fname-fromcache" );
                        
                        # If there's nothing in memcached, load all the messages from the database
                        if ( !$this->mCache ) {
@@ -53,12 +63,16 @@ class MessageCache
                                # Other threads don't need to load the messages if another thread is doing it.
                                $success = $this->mMemc->set( $this->mMemcKey, "loading", MSG_LOAD_TIMEOUT );
                                if ( $success ) {
+                                       wfProfileIn( "$fname-load" );
                                        $this->loadFromDB();
+                                       wfProfileOut( "$fname-load" );
                                        # Save in memcached
                                        # Keep trying if it fails, this is kind of important
+                                       wfProfileIn( "$fname-save" );
                                        for ( $i=0; $i<20 && !$this->mMemc->set( $this->mMemcKey, $this->mCache, $this->mExpiry ); $i++ ) {
                                                usleep(mt_rand(500000,1500000));
                                        }
+                                       wfProfileOut( "$fname-save" );
                                        if ( $i == 20 ) {
                                                $this->mMemc->set( $this->mMemcKey, "error", 86400 );
                                                wfDebug( "MemCached set error in MessageCache: restart memcached server!\n" );
@@ -85,6 +99,7 @@ class MessageCache
                                $this->mCache = false;
                        }
                }
+               wfProfileOut( $fname );
                return $success;
        }
 
index 205b1bf..4af8633 100644 (file)
@@ -2669,7 +2669,9 @@ class ParserOptions
        # Get user options
        function initialiseFromUser( &$userInput ) {
                global $wgUseTeX, $wgUseCategoryMagic, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
-
+               
+               $fname = "ParserOptions::initialiseFromUser";
+               wfProfileIn( $fname );
                if ( !$userInput ) {
                        $user = new User;
                        $user->setLoaded( true );
@@ -2682,12 +2684,15 @@ class ParserOptions
                $this->mUseDynamicDates = $wgUseDynamicDates;
                $this->mInterwikiMagic = $wgInterwikiMagic;
                $this->mAllowExternalImages = $wgAllowExternalImages;
+               wfProfileIn( "$fname-skin" );
                $this->mSkin =& $user->getSkin();
+               wfProfileOut( "$fname-skin" );
                $this->mDateFormat = $user->getOption( 'date' );
                $this->mEditSection = $user->getOption( 'editsection' );
                $this->mEditSectionOnRightClick = $user->getOption( 'editsectiononrightclick' );
                $this->mNumberHeadings = $user->getOption( 'numberheadings' );
                $this->mShowToc = $user->getOption( 'showtoc' );
+               wfProfileOut( $fname );
        }