(part of bug 6100) Set the directionality based on user language instead of content...
[lhc/web/wiklou.git] / includes / profiler / ProfilerSimpleText.php
1 <?php
2 /**
3 * @file
4 * @ingroup Profiler
5 */
6
7 /**
8 * The least sophisticated profiler output class possible, view your source! :)
9 *
10 * Put the following 2 lines in StartProfiler.php:
11 *
12 * $wgProfiler['class'] = 'ProfilerSimpleText';
13 * $wgProfiler['visible'] = true;
14 *
15 * @ingroup Profiler
16 */
17 class ProfilerSimpleText extends ProfilerSimple {
18 public $visible=false; /* Show as <PRE> or <!-- ? */
19 static private $out;
20
21 public function __construct( $profileConfig ) {
22 if( isset( $profileConfig['visible'] ) && $profileConfig['visible'] ) {
23 $this->visible = true;
24 }
25 parent::__construct( $profileConfig );
26 }
27
28 public function logData() {
29 if($this->mTemplated) {
30 uasort($this->mCollated,array('self','sort'));
31 array_walk($this->mCollated,array('self','format'));
32 if ($this->visible) {
33 print '<pre>'.self::$out.'</pre>';
34 } else {
35 print "<!--\n".self::$out."\n-->\n";
36 }
37 }
38 }
39
40 /* dense is good */
41 static function sort($a,$b) { return $a['real']<$b['real']; /* sort descending by time elapsed */ }
42 static function format($item,$key) { self::$out .= sprintf("%3.6f %6d - %s\n",$item['real'],$item['count'], $key); }
43 }