Follow up r75429 : benchmark for wfIsWindows();
[lhc/web/wiklou.git] / maintenance / benchmarks / bench_wfIsWindows.php
1 <?php
2 /**
3 * This come from r75429 message
4 * @author Platonides
5 */
6
7 require_once( dirname( __FILE__ ) . '/Benchmarker.php' );
8 class bench_wfIsWindows extends Benchmarker {
9
10 public function __construct() {
11 parent::__construct();
12 }
13
14 public function execute() {
15 $this->bench( array(
16 array( 'function' => array( $this, 'wfIsWindows' ) ),
17 array( 'function' => array( $this, 'wfIsWindowsCached' ) ),
18 ));
19 print $this->getFormattedResults();
20 }
21
22 static function is_win() {
23 return substr( php_uname(), 0, 7 == 'Windows' );
24 }
25
26 // bench function 1
27 function wfIsWindows() {
28 if( self::is_win() ) {
29 return true;
30 } else {
31 return false;
32 }
33 }
34
35 // bench function 2
36 function wfIsWindowsCached() {
37 static $isWindows = null;
38 if( $isWindows == null ) {
39 $isWindows = self::is_win();
40 }
41 return $isWindows;
42 }
43 }
44
45 $maintClass = 'bench_wfIsWindows';
46 require_once( DO_MAINTENANCE );