Skip to content

Instantly share code, notes, and snippets.

@ashleyhindle
Created December 2, 2014 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashleyhindle/c75334296de32969d1e1 to your computer and use it in GitHub Desktop.
Save ashleyhindle/c75334296de32969d1e1 to your computer and use it in GitHub Desktop.
<?php
echo "500000 loops of \$foo = array('i' => \$i);\n";
$start = microtime(true);
for ($i=0; $i < 500000; $i++) {
$foo = array(
'i' => $i
);
}
$end = microtime(true);
$timeTook = $end - $start;
echo "LongTook: {$timeTook}\n";
$start = microtime(true);
for ($i=0; $i < 500000; $i++) {
$foo = [
'i' => $i
];
}
$end = microtime(true);
$timeTook = $end - $start;
echo "ShortTook: {$timeTook}\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment