PHP 8.5.0 Alpha 1 available for testing

Voting

: min(nine, six)?
(Example: nine)

The Note You're Voting On

bens at effortlessis dot com
4 years ago
On my system (5th gen i7) random_int() takes about 14x longer to do the same number of calculations than rand().

for ($i=0; $i<10000000; $i++)
$x = rand(1, PHP_INT_MAX);

Takes 0.86 seconds for rand(), 12.29 seconds for random_int(). So use random_int() somewhat sparingly.

If it's not really important to be truly random, use rand() instead, especially in a tight loop.

<< Back to user notes page

To Top