* Update some documentation
[lhc/web/wiklou.git] / includes / ProfilerSimpleText.php
1 <?php
2 require_once( dirname( __FILE__ ) . '/ProfilerSimple.php' );
3
4 /**
5 * The least sophisticated profiler output class possible, view your source! :)
6 *
7 * Put it to StartProfiler.php like this:
8 *
9 * require_once( dirname( __FILE__ ) . '/includes/ProfilerSimpleText.php' );
10 * $wgProfiler = new ProfilerSimpleText;
11 * $wgProfiler->visible=true;
12 *
13 * @addtogroup Profiler
14 */
15 class ProfilerSimpleText extends ProfilerSimple {
16 public $visible=false; /* Show as <PRE> or <!-- ? */
17
18 function getFunctionReport() {
19 if ($this->visible) print "<pre>";
20 else print "<!--\n";
21 uasort($this->mCollated,array('self','sort'));
22 array_walk($this->mCollated,array('self','format'));
23 if ($this->visible) print "</pre>\n";
24 else print "-->\n";
25 }
26
27 /* dense is good */
28 static function sort($a,$b) { return $a['real']<$b['real']; /* sort descending by time elapsed */ }
29 static function format($item,$key) { printf("%3.6f %6d - %s\n",$item['real'],$item['count'], $key); }
30 }