r91441 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91440‎ | r91441 | r91442 >
Date:06:39, 5 July 2011
Author:aaron
Status:resolved
Tags:
Comment:
Added percentages to ProfilerSimpleText
Modified paths:
  • /trunk/phase3/includes/profiler/ProfilerSimpleText.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/profiler/ProfilerSimpleText.php
@@ -15,21 +15,23 @@
1616 * @ingroup Profiler
1717 */
1818 class ProfilerSimpleText extends ProfilerSimple {
19 - public $visible=false; /* Show as <PRE> or <!-- ? */
 19+ public $visible = false; /* Show as <PRE> or <!-- ? */
2020 static private $out;
2121
2222 public function __construct( $profileConfig ) {
23 - if( isset( $profileConfig['visible'] ) && $profileConfig['visible'] ) {
 23+ if ( isset( $profileConfig['visible'] ) && $profileConfig['visible'] ) {
2424 $this->visible = true;
2525 }
2626 parent::__construct( $profileConfig );
2727 }
2828
2929 public function logData() {
30 - if($this->mTemplated) {
31 - uasort($this->mCollated,array('self','sort'));
32 - array_walk($this->mCollated,array('self','format'));
33 - if ($this->visible) {
 30+ if ( $this->mTemplated ) {
 31+ $this->close();
 32+ $totalReal = $this->mCollated['-total']['real'];
 33+ uasort( $this->mCollated, array('self','sort') );
 34+ array_walk( $this->mCollated, array('self','format'), $totalReal );
 35+ if ( $this->visible ) {
3436 print '<pre>'.self::$out.'</pre>';
3537 } else {
3638 print "<!--\n".self::$out."\n-->\n";
@@ -38,6 +40,12 @@
3941 }
4042
4143 /* dense is good */
42 - static function sort($a,$b) { return $a['real']<$b['real']; /* sort descending by time elapsed */ }
43 - static function format($item,$key) { self::$out .= sprintf("%3.6f %6d - %s\n",$item['real'],$item['count'], $key); }
 44+ static function sort( $a, $b ) {
 45+ return $a['real'] < $b['real']; /* sort descending by time elapsed */
 46+ }
 47+
 48+ static function format( $item, $key, $totalReal ) {
 49+ self::$out .= sprintf( "%6.2f%% %3.6f %6d - %s\n",
 50+ $item['real']/$totalReal*100, $item['real'], $item['count'], $key );
 51+ }
4452 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r91503Division by zeroaaron22:47, 5 July 2011
r92119Avoid notice on profile close errorsaaron22:59, 13 July 2011
r93808removing a comment that doesn't make any sense after r91441 refactoring :-)midom08:00, 3 August 2011

Status & tagging log