Index: trunk/phase3/includes/profiler/ProfilerSimpleText.php |
— | — | @@ -15,21 +15,23 @@ |
16 | 16 | * @ingroup Profiler |
17 | 17 | */ |
18 | 18 | class ProfilerSimpleText extends ProfilerSimple { |
19 | | - public $visible=false; /* Show as <PRE> or <!-- ? */ |
| 19 | + public $visible = false; /* Show as <PRE> or <!-- ? */ |
20 | 20 | static private $out; |
21 | 21 | |
22 | 22 | public function __construct( $profileConfig ) { |
23 | | - if( isset( $profileConfig['visible'] ) && $profileConfig['visible'] ) { |
| 23 | + if ( isset( $profileConfig['visible'] ) && $profileConfig['visible'] ) { |
24 | 24 | $this->visible = true; |
25 | 25 | } |
26 | 26 | parent::__construct( $profileConfig ); |
27 | 27 | } |
28 | 28 | |
29 | 29 | 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 ) { |
34 | 36 | print '<pre>'.self::$out.'</pre>'; |
35 | 37 | } else { |
36 | 38 | print "<!--\n".self::$out."\n-->\n"; |
— | — | @@ -38,6 +40,12 @@ |
39 | 41 | } |
40 | 42 | |
41 | 43 | /* 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 | + } |
44 | 52 | } |