MediaWiki REL1_31
bench_wfIsWindows.php
Go to the documentation of this file.
1<?php
27require_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;
68require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance script that benchmarks wfIsWindows().
execute()
Do the actual work.
__construct()
Default constructor.
Base class for benchmark scripts.
bench(array $benchs)
addDescription( $text)
Set the description text.
require_once RUN_MAINTENANCE_IF_MAIN