profiling improvements and bug fixes
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 25 Jul 2005 07:00:20 +0000 (07:00 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 25 Jul 2005 07:00:20 +0000 (07:00 +0000)
includes/EditPage.php
includes/OutputPage.php
includes/Parser.php
includes/Profiling.php
includes/Setup.php

index af4ab97..6304cef 100644 (file)
@@ -923,12 +923,16 @@ END
         * @todo document
         */
        function mergeChangesInto( &$editText ){
+               $fname = 'EditPage::mergeChangesInto';
+               wfProfileIn( $fname );
+
                $db =& wfGetDB( DB_MASTER );
                
                // This is the revision the editor started from
                $baseRevision = Revision::loadFromTimestamp(
                        $db, $this->mArticle->mTitle, $this->edittime );
                if( is_null( $baseRevision ) ) {
+                       wfProfileOut( $fname );
                        return false;
                }
                $baseText = $baseRevision->getText();
@@ -937,14 +941,17 @@ END
                $currentRevision =  Revision::loadFromTitle(
                        $db, $this->mArticle->mTitle );
                if( is_null( $currentRevision ) ) {
+                       wfProfileOut( $fname );
                        return false;
                }
                $currentText = $currentRevision->getText();
                
                if( wfMerge( $baseText, $editText, $currentText, $result ) ){
                        $editText = $result;
+                       wfProfileOut( $fname );
                        return true;
                } else {
+                       wfProfileOut( $fname );
                        return false;
                }
        }
index 0c4f067..ae4694b 100644 (file)
@@ -438,6 +438,7 @@ class OutputPage {
                                header( 'Location: '.$this->mRedirect );
                        }
                        if ( isset( $wgProfiler ) ) { wfDebug( $wgProfiler->getOutput() ); }
+                       wfProfileOut( $fname );
                        return;
                }
 
@@ -468,6 +469,7 @@ class OutputPage {
 
                $this->sendCacheControl();
                ob_end_flush();
+               wfProfileOut( $fname );
        }
 
        function out( $ins ) {
index e4746a9..280e5af 100644 (file)
@@ -1161,7 +1161,7 @@ class Parser
                                $s .= $protocol . $remainder;
                        }
                }
-               wfProfileOut();
+               wfProfileOut( $fname );
                return $s;
        }
 
index 26238d7..770f39f 100755 (executable)
@@ -58,14 +58,12 @@ class Profiler {
                if ($wgDebugFunctionEntry && function_exists('wfDebug')) {
                        wfDebug(str_repeat(' ', count($this->mWorkStack)).'Entering '.$functionname."\n");
                }
-               $this->mWorkStack[] = array($functionname, count($this->mWorkStack), microtime(), memory_get_usage());
-               #$this->mWorkStack[] = array($functionname, count( $this->mWorkStack ), $this->getUserTime(), memory_get_usage());
+               $this->mWorkStack[] = array($functionname, count( $this->mWorkStack ), $this->getTime(), memory_get_usage());
        }
 
        function profileOut($functionname) {
                $memory = memory_get_usage();
-               $time = microtime();
-               #$time = $this->getUserTime();
+               $time = $this->getTime();
 
                global $wgDebugProfiling, $wgDebugFunctionEntry;
 
@@ -78,14 +76,18 @@ class Profiler {
                if (!$bit) {
                        wfDebug("Profiling error, !\$bit: $functionname\n");
                } else {
-                       if ($wgDebugProfiling) {
+                       //if ($wgDebugProfiling) {
                                if ($functionname == 'close') {
-                                       wfDebug("Profile section ended by close(): {$bit[0]}\n");
+                                       $message = "Profile section ended by close(): {$bit[0]}\n";
+                                       wfDebug( $message );
+                                       $this->mStack[] = array( $message, 0, 0, 0 );
                                }
                                elseif ($bit[0] != $functionname) {
-                                       wfDebug("Profiling error: in({$bit[0]}), out($functionname)\n");
+                                       $message = "Profiling error: in({$bit[0]}), out($functionname)\n";
+                                       wfDebug( $message );
+                                       $this->mStack[] = array( $message, 0, 0, 0 );
                                }
-                       }
+                       //}
                        $bit[] = $time;
                        $bit[] = $memory;
                        $this->mStack[] = $bit;
@@ -176,6 +178,11 @@ class Profiler {
                       $this->micro2Float( $start );
        }
 
+       function getTime() {
+               return microtime();
+               #return $this->getUserTime();
+       }
+
        function getUserTime() {
                $ru = getrusage();
                return $ru['ru_utime.tv_sec'].' '.$ru['ru_utime.tv_usec'] / 1e6;
index 7f5b6a4..1a580c1 100644 (file)
@@ -233,7 +233,7 @@ if( $wgLangClass == $wgContLangClass ) {
        $wgLang = setupLangObj( $wgLangClass );
 }
 
-wfProfileOut( $fname.'-language' );
+wfProfileOut( $fname.'-language2' );
 wfProfileIn( $fname.'-MessageCache' );
 
 $wgMessageCache = new MessageCache;