Skip to content

Instantly share code, notes, and snippets.

@tmotyl
Last active August 29, 2015 14:02
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 tmotyl/51ad04496251c10c2ead to your computer and use it in GitHub Desktop.
Save tmotyl/51ad04496251c10c2ead to your computer and use it in GitHub Desktop.
Uniqid performance
$start = microtime(true);
for ($i = 0; $i < 50000; $i++) { uniqid("NEW"); }
$stop = microtime(true);
$result = $stop-$start;
echo "50000: " . $result . "s\n";
echo "1op " . $result / 50000 . "s\n";
$start = microtime(true);
for ($i = 0; $i < 50000; $i++) { uniqid("NEW", true); }
$stop = microtime(true);
$result = $stop-$start;
echo "TRUE\n";
echo "50000: " . $result . "s\n";
echo "1op " . $result / 50000 . "s\n";
==============
RESULTS on PHP 5.5.3-1ubuntu2.3 (cli), without virtualization
50000: 3.0598292350769s
1op 6.1196584701538E-5s
TRUE
50000: 0.10254096984863s
1op 2.0508193969727E-6s
On windows 7 on virtual machine
====
50000: 0.28189897537231s
1op 5.6379795074463E-6s
TRUE
50000: 0.3240339756012s
1op 6.4806795120239E-6s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment