Created
March 26, 2013 16:04
-
-
Save iNem0o/5246631 to your computer and use it in GitHub Desktop.
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 | |
$data = array(); | |
for($i = 0;$i<= 10000;$i++) { | |
$data[md5($i)] = $i; | |
} | |
$start = microtime(true); | |
foreach($data as $k => $v) { | |
$data[$k] = 'benchkmark'; | |
} | |
echo '<br>$k => $v : '.round((microtime(true) - $start)*1000,2).' ms'; | |
$start = microtime(true); | |
foreach($data as &$v) { | |
$v = 'benchkmark'; | |
} | |
echo '<br>&$v : '.round((microtime(true) - $start)*1000,2).' ms'; | |
?> | |
Résultat pour 10000 itérations : | |
$k => $v : 9.72 ms | |
&$v : 3.11 ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment