ProfilerSimpleText.php 1011 B

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