note 105617 deleted from control-structures.elseif by danbrown
| From: | danbrown@php.net | Date: | Thu, 01 Sep 2011 20:26:11 +0000 |
| Subject: | note 105617 deleted from control-structures.elseif by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-182891@lists.php.net to get a copy of this message | ||
Note Submitter: Kevin Namuag
----
In Addition to Rudy's else/else if speed testing.
if(condition): elseif(condition): else: endif; is the slowest else/elseif.
<?php
$start = microtime(true);
for($i = 0; $i < 100000000; $i++) {
if(2 === 0) {} else if(2 === 1) {} else {}
}
$end = microtime(true);
echo "1: ".($end - $start)."<br />";
unset($start, $end);
$start = microtime(true);
for($i = 0; $i < 100000000; $i++) {
if(2 === 0) {} elseif(2 === 1) {} else {}
}
$end = microtime(true);
echo "2: ".($end - $start) ."<br />";
for($i = 0; $i < 100000000; $i++) {
if(2 === 0):elseif(2 === 1):else:endif;
}
$end = microtime(true);
echo "3: ".($end - $start) ."<br />";
?>
== Result
1: 14.427691221237
2: 14.069947004318
3: 27.981864929199