Skip to content

Instantly share code, notes, and snippets.

@iNem0o
Created March 26, 2013 16:04
Show Gist options
  • Save iNem0o/5246631 to your computer and use it in GitHub Desktop.
Save iNem0o/5246631 to your computer and use it in GitHub Desktop.
<?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