MediaWiki  master
bench_wfIsWindows.php
Go to the documentation of this file.
1 <?php
27 require_once __DIR__ . '/Benchmarker.php';
28 
35  public function __construct() {
36  parent::__construct();
37  $this->addDescription( 'Benchmark for wfIsWindows.' );
38  }
39 
40  public function execute() {
41  $this->bench( [
42  [ 'function' => [ $this, 'wfIsWindows' ] ],
43  [ 'function' => [ $this, 'wfIsWindowsCached' ] ],
44  ] );
45  }
46 
47  protected static function is_win() {
48  return substr( php_uname(), 0, 7 ) == 'Windows';
49  }
50 
51  // bench function 1
52  protected function wfIsWindows() {
53  return self::is_win();
54  }
55 
56  // bench function 2
57  protected function wfIsWindowsCached() {
58  static $isWindows = null;
59  if ( $isWindows == null ) {
60  $isWindows = self::is_win();
61  }
62 
63  return $isWindows;
64  }
65 }
66 
67 $maintClass = BenchWfIsWindows::class;
68 require_once RUN_MAINTENANCE_IF_MAIN;
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:39
bench(array $benchs)
Definition: Benchmarker.php:51
addDescription( $text)
Set the description text.
Base class for benchmark scripts.
Definition: Benchmarker.php:41
Maintenance script that benchmarks wfIsWindows().