Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -350,12 +350,14 @@ |
351 | 351 | */ |
352 | 352 | function wfLogProfilingData() { |
353 | 353 | 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 |
358 | 358 | $now = wfTime(); |
359 | 359 | $elapsed = $now - $wgRequestTime; |
| 360 | + # Only show pages that longer than $wgProfileLimit time (default is 0) |
| 361 | + if( $elapsed <= $wgProfileLimit ) return; |
360 | 362 | $prof = wfGetProfilingOutput( $wgRequestTime, $elapsed ); |
361 | 363 | $forward = ''; |
362 | 364 | if( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) |
Index: trunk/phase3/includes/Profiler.php |
— | — | @@ -145,7 +145,12 @@ |
146 | 146 | } |
147 | 147 | $this->close(); |
148 | 148 | |
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 | + } |
150 | 155 | return $this->getCallTree(); |
151 | 156 | } else { |
152 | 157 | return $this->getFunctionReport(); |
— | — | @@ -202,16 +207,13 @@ |
203 | 208 | /** |
204 | 209 | * Callback to get a formatted line for the call tree |
205 | 210 | */ |
206 | | - function getCallTreeLine($entry) { |
| 211 | + function getCallTreeLine( $entry ) { |
207 | 212 | list( $fname, $level, $start, /* $x */, $end) = $entry; |
208 | 213 | $delta = $end - $start; |
209 | 214 | $space = str_repeat(' ', $level); |
210 | | - |
211 | 215 | # The ugly double sprintf is to work around a PHP bug, |
212 | 216 | # 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 ); |
216 | 218 | } |
217 | 219 | |
218 | 220 | function getTime() { |
— | — | @@ -316,8 +318,8 @@ |
317 | 319 | $percent = $total ? 100. * $elapsed / $total : 0; |
318 | 320 | $memory = $this->mMemory[$fname]; |
319 | 321 | $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 ) { |
322 | 324 | self::logToDB($fname, (float) ($elapsed * 1000), $calls, (float) ($memory) ); |
323 | 325 | } |
324 | 326 | } |