MediaWiki  1.23.2
bench_if_switch.php
Go to the documentation of this file.
1 <?php
27 require_once __DIR__ . '/Benchmarker.php';
28 
35 
36  public function __construct() {
37  parent::__construct();
38  $this->mDescription = "Benchmark if elseif... versus switch case.";
39  }
40 
41  public function execute() {
42  $this->bench( array(
43  array( 'function' => array( $this, 'doElseIf' ) ),
44  array( 'function' => array( $this, 'doSwitch' ) ),
45  ));
46  print $this->getFormattedResults();
47  }
48 
49  // bench function 1
50  function doElseIf() {
51  $a = 'z';
52  if( $a == 'a') {}
53  elseif( $a == 'b') {}
54  elseif( $a == 'c') {}
55  elseif( $a == 'd') {}
56  elseif( $a == 'e') {}
57  elseif( $a == 'f') {}
58  elseif( $a == 'g') {}
59  elseif( $a == 'h') {}
60  elseif( $a == 'i') {}
61  elseif( $a == 'j') {}
62  elseif( $a == 'k') {}
63  elseif( $a == 'l') {}
64  elseif( $a == 'm') {}
65  elseif( $a == 'n') {}
66  elseif( $a == 'o') {}
67  elseif( $a == 'p') {}
68  else {}
69  }
70 
71  // bench function 2
72  function doSwitch() {
73  $a = 'z';
74  switch( $a ) {
75  case 'b': break;
76  case 'c': break;
77  case 'd': break;
78  case 'e': break;
79  case 'f': break;
80  case 'g': break;
81  case 'h': break;
82  case 'i': break;
83  case 'j': break;
84  case 'k': break;
85  case 'l': break;
86  case 'm': break;
87  case 'n': break;
88  case 'o': break;
89  case 'p': break;
90  default:
91  }
92  }
93 }
94 
95 $maintClass = 'bench_if_switch';
96 require_once RUN_MAINTENANCE_IF_MAIN;
bench_if_switch\doElseIf
doElseIf()
Definition: bench_if_switch.php:50
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
bench_if_switch
Maintenance script that benchmark if elseif...
Definition: bench_if_switch.php:34
Benchmarker\getFormattedResults
getFormattedResults()
Definition: Benchmarker.php:78
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Benchmarker\bench
bench(array $benchs)
Definition: Benchmarker.php:45
bench_if_switch\__construct
__construct()
Default constructor.
Definition: bench_if_switch.php:36
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
bench_if_switch\doSwitch
doSwitch()
Definition: bench_if_switch.php:72
Benchmarker
Base class for benchmark scripts.
Definition: Benchmarker.php:37
bench_if_switch\execute
execute()
Do the actual work.
Definition: bench_if_switch.php:41
$maintClass
$maintClass
Definition: bench_if_switch.php:95