summaryrefslogtreecommitdiff
path: root/maintenance/benchmarks/bench_if_switch.php
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/benchmarks/bench_if_switch.php')
-rw-r--r--maintenance/benchmarks/bench_if_switch.php89
1 files changed, 52 insertions, 37 deletions
diff --git a/maintenance/benchmarks/bench_if_switch.php b/maintenance/benchmarks/bench_if_switch.php
index 80fd9623..698a0f0a 100644
--- a/maintenance/benchmarks/bench_if_switch.php
+++ b/maintenance/benchmarks/bench_if_switch.php
@@ -31,8 +31,7 @@ require_once __DIR__ . '/Benchmarker.php';
*
* @ingroup Maintenance
*/
-class bench_if_switch extends Benchmarker {
-
+class BenchIfSwitch extends Benchmarker {
public function __construct() {
parent::__construct();
$this->mDescription = "Benchmark if elseif... versus switch case.";
@@ -42,55 +41,71 @@ class bench_if_switch extends Benchmarker {
$this->bench( array(
array( 'function' => array( $this, 'doElseIf' ) ),
array( 'function' => array( $this, 'doSwitch' ) ),
- ));
+ ) );
print $this->getFormattedResults();
}
// bench function 1
function doElseIf() {
$a = 'z';
- if( $a == 'a') {}
- elseif( $a == 'b') {}
- elseif( $a == 'c') {}
- elseif( $a == 'd') {}
- elseif( $a == 'e') {}
- elseif( $a == 'f') {}
- elseif( $a == 'g') {}
- elseif( $a == 'h') {}
- elseif( $a == 'i') {}
- elseif( $a == 'j') {}
- elseif( $a == 'k') {}
- elseif( $a == 'l') {}
- elseif( $a == 'm') {}
- elseif( $a == 'n') {}
- elseif( $a == 'o') {}
- elseif( $a == 'p') {}
- else {}
+ if ( $a == 'a' ) {
+ } elseif ( $a == 'b' ) {
+ } elseif ( $a == 'c' ) {
+ } elseif ( $a == 'd' ) {
+ } elseif ( $a == 'e' ) {
+ } elseif ( $a == 'f' ) {
+ } elseif ( $a == 'g' ) {
+ } elseif ( $a == 'h' ) {
+ } elseif ( $a == 'i' ) {
+ } elseif ( $a == 'j' ) {
+ } elseif ( $a == 'k' ) {
+ } elseif ( $a == 'l' ) {
+ } elseif ( $a == 'm' ) {
+ } elseif ( $a == 'n' ) {
+ } elseif ( $a == 'o' ) {
+ } elseif ( $a == 'p' ) {
+ } else {
+ }
}
// bench function 2
function doSwitch() {
$a = 'z';
- switch( $a ) {
- case 'b': break;
- case 'c': break;
- case 'd': break;
- case 'e': break;
- case 'f': break;
- case 'g': break;
- case 'h': break;
- case 'i': break;
- case 'j': break;
- case 'k': break;
- case 'l': break;
- case 'm': break;
- case 'n': break;
- case 'o': break;
- case 'p': break;
+ switch ( $a ) {
+ case 'b':
+ break;
+ case 'c':
+ break;
+ case 'd':
+ break;
+ case 'e':
+ break;
+ case 'f':
+ break;
+ case 'g':
+ break;
+ case 'h':
+ break;
+ case 'i':
+ break;
+ case 'j':
+ break;
+ case 'k':
+ break;
+ case 'l':
+ break;
+ case 'm':
+ break;
+ case 'n':
+ break;
+ case 'o':
+ break;
+ case 'p':
+ break;
default:
}
}
}
-$maintClass = 'bench_if_switch';
+$maintClass = 'BenchIfSwitch';
require_once RUN_MAINTENANCE_IF_MAIN;