MediaWiki
REL1_35
bench_if_switch.php
Go to the documentation of this file.
1
<?php
27
require_once __DIR__ .
'/../includes/Benchmarker.php'
;
28
34
class
BenchIfSwitch
extends
Benchmarker
{
35
public
function
__construct
() {
36
parent::__construct();
37
$this->
addDescription
(
'Benchmark if elseif... versus switch case.'
);
38
}
39
40
public
function
execute
() {
41
$this->
bench
( [
42
[
'function'
=> [ $this,
'doElseIf'
] ],
43
[
'function'
=> [ $this,
'doSwitch'
] ],
44
] );
45
}
46
51
protected
function
doElseIf
() {
52
$a =
'z'
;
53
if
( $a ==
'a'
) {
54
} elseif ( $a ==
'b'
) {
55
} elseif ( $a ==
'c'
) {
56
} elseif ( $a ==
'd'
) {
57
} elseif ( $a ==
'e'
) {
58
} elseif ( $a ==
'f'
) {
59
} elseif ( $a ==
'g'
) {
60
} elseif ( $a ==
'h'
) {
61
} elseif ( $a ==
'i'
) {
62
} elseif ( $a ==
'j'
) {
63
} elseif ( $a ==
'k'
) {
64
} elseif ( $a ==
'l'
) {
65
} elseif ( $a ==
'm'
) {
66
} elseif ( $a ==
'n'
) {
67
} elseif ( $a ==
'o'
) {
68
} elseif ( $a ==
'p'
) {
69
}
else
{
70
}
71
}
72
76
protected
function
doSwitch
() {
77
$a =
'z'
;
78
switch
( $a ) {
79
case
'b'
:
80
break
;
81
case
'c'
:
82
break
;
83
case
'd'
:
84
break
;
85
case
'e'
:
86
break
;
87
case
'f'
:
88
break
;
89
case
'g'
:
90
break
;
91
case
'h'
:
92
break
;
93
case
'i'
:
94
break
;
95
case
'j'
:
96
break
;
97
case
'k'
:
98
break
;
99
case
'l'
:
100
break
;
101
case
'm'
:
102
break
;
103
case
'n'
:
104
break
;
105
case
'o'
:
106
break
;
107
case
'p'
:
108
break
;
109
default
:
110
}
111
}
112
}
113
114
$maintClass
= BenchIfSwitch::class;
115
require_once
RUN_MAINTENANCE_IF_MAIN
;
RUN_MAINTENANCE_IF_MAIN
const RUN_MAINTENANCE_IF_MAIN
Definition
Maintenance.php:38
$maintClass
$maintClass
Definition
bench_if_switch.php:114
BenchIfSwitch
Maintenance script that benchmark if elseif... versus switch case.
Definition
bench_if_switch.php:34
BenchIfSwitch\execute
execute()
Do the actual work.
Definition
bench_if_switch.php:40
BenchIfSwitch\doElseIf
doElseIf()
bench function 1 PhanSuspiciousValueComparison
Definition
bench_if_switch.php:51
BenchIfSwitch\__construct
__construct()
Default constructor.
Definition
bench_if_switch.php:35
BenchIfSwitch\doSwitch
doSwitch()
bench function 2
Definition
bench_if_switch.php:76
Benchmarker
Base class for benchmark scripts.
Definition
Benchmarker.php:41
Benchmarker\bench
bench(array $benchs)
Definition
Benchmarker.php:51
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition
Maintenance.php:325
maintenance
benchmarks
bench_if_switch.php
Generated on Sat Apr 6 2024 00:08:21 for MediaWiki by
1.9.8