Created
January 16, 2013 07:37
-
-
Save emaniacs/4545317 to your computer and use it in GitHub Desktop.
Big integer random performance.
Using rand() function and looping.
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 | |
$t1Start = microtime(true); | |
$rand1 = rand(100000, 1000000); | |
$t1End = microtime(true); | |
//sleep(3); | |
$rand2 = ''; | |
$length = 6; | |
$t2Start = microtime(true); | |
for ($x = 0; $x < $length; ++$x, $rand2.=rand(0,9)); | |
$t2End = microtime(true); | |
echo 'First Random: Value(', $rand1, '), Start(', $t1Start, '), End(', $t1End, '), Diff(', ($t1End-$t1Start), ")\n"; | |
echo 'Second Random: Value(', $rand2, '), Start(', $t2Start, '), End(', $t2End, '), Diff(', ($t2End-$t2Start), ")\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment