Created
November 26, 2014 14:59
-
-
Save nicolas-grekas/0e70b9feabfbded21b85 to your computer and use it in GitHub Desktop.
Speed PHP benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$len = 1000000; | |
$a = range(1, $len); | |
$f = SplFixedArray::fromArray($a); | |
$s = microtime(1); | |
$i = $len; | |
while (--$i) { | |
#1 | |
$b = $a[$i]; | |
} | |
echo 1000*(microtime(1)-$s), "\n"; | |
$s = microtime(1); | |
$proto = array('r'=>4); | |
$i = $len; | |
while (--$i) { | |
#2 | |
$b = $f[$i]; | |
} | |
echo 1000*(microtime(1)-$s), "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment