From: Tim Starling Date: Mon, 25 Jul 2005 07:00:20 +0000 (+0000) Subject: profiling improvements and bug fixes X-Git-Tag: 1.5.0beta4~35 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=7c900a732a6bfa2d060e28a4260591ff0ea69c14;p=lhc%2Fweb%2Fwiklou.git profiling improvements and bug fixes --- diff --git a/includes/EditPage.php b/includes/EditPage.php index af4ab9733b..6304cef18a 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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; } } diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 0c4f0672b6..ae4694bc48 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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 ) { diff --git a/includes/Parser.php b/includes/Parser.php index e4746a95b3..280e5afdb6 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -1161,7 +1161,7 @@ class Parser $s .= $protocol . $remainder; } } - wfProfileOut(); + wfProfileOut( $fname ); return $s; } diff --git a/includes/Profiling.php b/includes/Profiling.php index 26238d7d3b..770f39fedd 100755 --- a/includes/Profiling.php +++ b/includes/Profiling.php @@ -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; diff --git a/includes/Setup.php b/includes/Setup.php index 7f5b6a4c9a..1a580c163d 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -233,7 +233,7 @@ if( $wgLangClass == $wgContLangClass ) { $wgLang = setupLangObj( $wgLangClass ); } -wfProfileOut( $fname.'-language' ); +wfProfileOut( $fname.'-language2' ); wfProfileIn( $fname.'-MessageCache' ); $wgMessageCache = new MessageCache;