8 * The least sophisticated profiler output class possible, view your source! :)
10 * Put the following 2 lines in StartProfiler.php:
12 * $wgProfiler['class'] = 'ProfilerSimpleText';
13 * $wgProfiler['visible'] = true;
17 class ProfilerSimpleText
extends ProfilerSimple
{
18 public $visible = false; /* Show as <PRE> or <!-- ? */
21 public function __construct( $profileConfig ) {
22 if ( isset( $profileConfig['visible'] ) && $profileConfig['visible'] ) {
23 $this->visible
= true;
25 parent
::__construct( $profileConfig );
28 public function logData() {
29 if ( $this->mTemplated
) {
31 $totalReal = isset( $this->mCollated
['-total'] )
32 ?
$this->mCollated
['-total']['real']
33 : 0; // profiling mismatch error?
34 uasort( $this->mCollated
, array('self','sort') );
35 array_walk( $this->mCollated
, array('self','format'), $totalReal );
36 if ( $this->visible
) {
37 print '<pre>'.self
::$out.'</pre>';
39 print "<!--\n".self
::$out."\n-->\n";
44 static function sort( $a, $b ) {
45 return $a['real'] < $b['real']; /* sort descending by time elapsed */
48 static function format( $item, $key, $totalReal ) {
49 $perc = $totalReal ?
$item['real']/$totalReal*100 : 0;
50 self
::$out .= sprintf( "%6.2f%% %3.6f %6d - %s\n",
51 $perc, $item['real'], $item['count'], $key );