Skip to content

Instantly share code, notes, and snippets.

@nicolas-grekas
Created November 26, 2014 14:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolas-grekas/0e70b9feabfbded21b85 to your computer and use it in GitHub Desktop.
Save nicolas-grekas/0e70b9feabfbded21b85 to your computer and use it in GitHub Desktop.
Speed PHP benchmark
<?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