r47739 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47738‎ | r47739 | r47740 >
Date:09:50, 24 February 2009
Author:aaron
Status:ok
Tags:
Comment:
* Fixed $wgProfileToDatabase/$wgProfileCallTree interaction (later disabled the former)
* Made $wgProfileLimit actually work (bug 17485)
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/Profiler.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -350,12 +350,14 @@
351351 */
352352 function wfLogProfilingData() {
353353 global $wgRequestTime, $wgDebugLogFile, $wgDebugRawPage, $wgRequest;
354 - global $wgProfiler, $wgUser;
355 - if ( !isset( $wgProfiler ) )
356 - return;
357 -
 354+ global $wgProfiler, $wgProfileLimit, $wgUser;
 355+ # Profiling must actually be enabled...
 356+ if( !isset( $wgProfiler ) ) return;
 357+ # Get total page request time
358358 $now = wfTime();
359359 $elapsed = $now - $wgRequestTime;
 360+ # Only show pages that longer than $wgProfileLimit time (default is 0)
 361+ if( $elapsed <= $wgProfileLimit ) return;
360362 $prof = wfGetProfilingOutput( $wgRequestTime, $elapsed );
361363 $forward = '';
362364 if( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) )
Index: trunk/phase3/includes/Profiler.php
@@ -145,7 +145,12 @@
146146 }
147147 $this->close();
148148
149 - if( $wgProfileCallTree ){
 149+ if( $wgProfileCallTree ) {
 150+ global $wgProfileToDatabase;
 151+ # XXX: We must call $this->getFunctionReport() to log to the DB
 152+ if( $wgProfileToDatabase ) {
 153+ $this->getFunctionReport();
 154+ }
150155 return $this->getCallTree();
151156 } else {
152157 return $this->getFunctionReport();
@@ -202,16 +207,13 @@
203208 /**
204209 * Callback to get a formatted line for the call tree
205210 */
206 - function getCallTreeLine($entry) {
 211+ function getCallTreeLine( $entry ) {
207212 list( $fname, $level, $start, /* $x */, $end) = $entry;
208213 $delta = $end - $start;
209214 $space = str_repeat(' ', $level);
210 -
211215 # The ugly double sprintf is to work around a PHP bug,
212216 # which has been fixed in recent releases.
213 - return sprintf( "%10s %s %s\n",
214 - trim( sprintf( "%7.3f", $delta * 1000.0 ) ),
215 - $space, $fname );
 217+ return sprintf( "%10s %s %s\n", trim( sprintf( "%7.3f", $delta * 1000.0 ) ), $space, $fname );
216218 }
217219
218220 function getTime() {
@@ -316,8 +318,8 @@
317319 $percent = $total ? 100. * $elapsed / $total : 0;
318320 $memory = $this->mMemory[$fname];
319321 $prof .= sprintf($format, substr($fname, 0, $nameWidth), $calls, (float) ($elapsed * 1000), (float) ($elapsed * 1000) / $calls, $percent, $memory, ($this->mMin[$fname] * 1000.0), ($this->mMax[$fname] * 1000.0), $this->mOverhead[$fname]);
320 -
321 - if( $wgProfileToDatabase ){
 322+ # Log to the DB
 323+ if( $wgProfileToDatabase ) {
322324 self::logToDB($fname, (float) ($elapsed * 1000), $calls, (float) ($memory) );
323325 }
324326 }

Status & tagging log