Index: branches/REL1_4/phase3/includes/Profiling.php |
— | — | @@ -20,9 +20,9 @@ |
21 | 21 | $wgProfiler->profileOut( $functionname ); |
22 | 22 | } |
23 | 23 | |
24 | | -function wfGetProfilingOutput( $start, $elapsed ) { |
| 24 | +function wfGetProfilingOutput() { |
25 | 25 | global $wgProfiler; |
26 | | - return $wgProfiler->getOutput( $start, $elapsed ); |
| 26 | + return $wgProfiler->getOutput(); |
27 | 27 | } |
28 | 28 | |
29 | 29 | function wfProfileClose() { |
— | — | @@ -179,9 +179,10 @@ |
180 | 180 | function getFunctionReport() { |
181 | 181 | $width = 125; |
182 | 182 | $format = "%-" . ($width - 34) . "s %6d %6.3f %6.3f %7.3f%% %6d (%6.3f-%6.3f) [%d]\n"; |
183 | | - $titleFormat = "%-" . ($width - 34) . "s %9s %9s %9s %9s %6s\n"; |
| 183 | + $titleFormat = "%-" . ($width - 34) . "s %9s %9s %9s %9s %9s %9s %9s %9s\n"; |
184 | 184 | $prof = "\nProfiling data\n"; |
185 | | - $prof .= sprintf( $titleFormat, 'Name', 'Calls', 'Total', 'Each', '%', 'Mem' ); |
| 185 | + $prof .= sprintf( $titleFormat, 'Name', 'Calls', 'Total', 'Each', '%', |
| 186 | + 'Mem', 'Min', 'Max', 'Overhead' ); |
186 | 187 | $this->mCollated = array(); |
187 | 188 | $this->mCalls = array(); |
188 | 189 | $this->mMemory = array(); |
— | — | @@ -258,12 +259,12 @@ |
259 | 260 | $this->mCalls['-overhead-total'] = $profileCount; |
260 | 261 | |
261 | 262 | # Output |
262 | | - asort( $this->mCollated, SORT_NUMERIC ); |
| 263 | + arsort( $this->mCollated, SORT_NUMERIC ); |
263 | 264 | foreach ( $this->mCollated as $fname => $elapsed ) { |
264 | 265 | $calls = $this->mCalls[$fname]; |
265 | 266 | $percent = $total ? 100. * $elapsed / $total : 0; |
266 | 267 | $memory = $this->mMemory[$fname]; |
267 | | - $prof .= sprintf( $format, $fname, $calls, (float)($elapsed * 1000), |
| 268 | + $prof .= sprintf( $format, substr( $fname, 0, $width-34), $calls, (float)($elapsed * 1000), |
268 | 269 | (float)($elapsed * 1000) / $calls, $percent, $memory, |
269 | 270 | ($this->mMin[$fname] * 1000.0), |
270 | 271 | ($this->mMax[$fname] * 1000.0), |
Index: branches/REL1_4/phase3/includes/GlobalFunctions.php |
— | — | @@ -292,7 +292,7 @@ |
293 | 293 | $start = (float)$sec + (float)$usec; |
294 | 294 | $elapsed = $now - $start; |
295 | 295 | if ( $wgProfiling ) { |
296 | | - $prof = wfGetProfilingOutput( $start, $elapsed ); |
| 296 | + $prof = wfGetProfilingOutput(); |
297 | 297 | $forward = ''; |
298 | 298 | if( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) |
299 | 299 | $forward = ' forwarded for ' . $_SERVER['HTTP_X_FORWARDED_FOR']; |
Index: branches/REL1_4/phase3/includes/OutputPage.php |
— | — | @@ -486,8 +486,21 @@ |
487 | 487 | * This method has no side effects. |
488 | 488 | */ |
489 | 489 | function reportTime() { |
490 | | - global $wgRequestTime; |
| 490 | + global $wgRequestTime, $wgProfiling, $wgProfileToCommentUser, $wgUser; |
491 | 491 | |
| 492 | + |
| 493 | + if ( $wgProfiling && $wgUser && $wgProfileToCommentUser && |
| 494 | + $wgProfileToCommentUser == $wgUser->getName() ) |
| 495 | + { |
| 496 | + $prof = wfGetProfilingOutput(); |
| 497 | + // Strip end of comment |
| 498 | + $prof = str_replace( '-->', '--<', $prof ); |
| 499 | + $com = "<!--\n$prof\n-->\n"; |
| 500 | + } else { |
| 501 | + $com = ''; |
| 502 | + } |
| 503 | + |
| 504 | + |
492 | 505 | $now = wfTime(); |
493 | 506 | list( $usec, $sec ) = explode( ' ', $wgRequestTime ); |
494 | 507 | $start = (float)$sec + (float)$usec; |
— | — | @@ -506,7 +519,7 @@ |
507 | 520 | # This may be a virtual server. |
508 | 521 | $hostname = $_SERVER['SERVER_NAME']; |
509 | 522 | } |
510 | | - $com = sprintf( "<!-- Served by %s in %01.2f secs. -->", |
| 523 | + $com .= sprintf( "<!-- Served by %s in %01.2f secs. -->\n", |
511 | 524 | $hostname, $elapsed ); |
512 | 525 | return $com; |
513 | 526 | } |
Index: branches/REL1_4/phase3/includes/DefaultSettings.php |
— | — | @@ -562,6 +562,7 @@ |
563 | 563 | $wgProfileToDatabase = false; # Log sums from profiling into "profiling" table in db. |
564 | 564 | $wgProfileSampleRate = 1; # Only profile every n requests when profiling is turned on |
565 | 565 | $wgProfileCallTree = false; # If true, print a raw call tree instead of per-function report |
| 566 | +$wgProfileToCommentUser = false; # Put profiling data in HTML comments in the output file, for a given user only |
566 | 567 | |
567 | 568 | $wgDebugProfiling = false; # Detects non-matching wfProfileIn/wfProfileOut calls |
568 | 569 | $wgDebugFunctionEntry = 0; # Output debug message on every wfProfileIn/wfProfileOut |