More profiler cleanup:
[lhc/web/wiklou.git] / includes / profiler / ProfilerStub.php
1 <?php
2 /**
3 * Stub profiling functions
4 * @file
5 * @ingroup Profiler
6 */
7 class ProfilerStub extends Profiler {
8
9 /**
10 * is setproctitle function available?
11 * @var bool
12 */
13 private $haveProctitle;
14 private $hackWhere = array();
15
16 /**
17 * Constructor. Check for proctitle.
18 */
19 public function __construct() {
20 $this->haveProctitle = function_exists( 'setproctitle' );
21 }
22
23 /**
24 * Begin profiling of a function
25 * @param $fn string
26 */
27 public function profileIn( $fn = '' ) {
28 global $wgDBname;
29 if( $this->haveProctitle ){
30 $this->hackWhere[] = $fn;
31 setproctitle( $fn . " [$wgDBname]" );
32 }
33 }
34
35 /**
36 * Stop profiling of a function
37 * @param $fn string
38 */
39 public function profileOut( $fn = '' ) {
40 global $wgDBname;
41 if( !$this->haveProctitle ) {
42 return;
43 }
44 if( count( $this->hackWhere ) ) {
45 array_pop( $this->hackWhere );
46 }
47 if( count( $this->hackWhere ) ) {
48 setproctitle( $this->hackWhere[count( $this->hackWhere )-1] . " [$wgDBname]" );
49 }
50 }
51
52 /**
53 * Does nothing, just for compatibility
54 */
55 public function getOutput() {}
56 public function close() {}
57 }