note 125333 added to function.random-int
| From: | bens.effortlessis.com via php-notes | Date: | Sat, 05 Sep 2020 16:21:45 +0000 |
| Subject: | note 125333 added to function.random-int | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-215077@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 45.112.84.4
Probable Submitter: 195.138.250.34 (proxied: 2600:100e:bf1c:611:cd50:c8ff:8b60:eaf6)
----
Manual Page -- http://php.net/manual/en/function.random-int.php
Edit -- https://master.php.net/note/edit/125333
Del: integrated -- https://master.php.net/note/delete/125333/integrated
Del: useless -- https://master.php.net/note/delete/125333/useless
Del: bad code -- https://master.php.net/note/delete/125333/bad+code
Del: spam -- https://master.php.net/note/delete/125333/spam
Del: non-english -- https://master.php.net/note/delete/125333/non-english
Del: in docs -- https://master.php.net/note/delete/125333/in+docs
Del: other reasons-- https://master.php.net/note/delete/125333
Reject -- https://master.php.net/note/reject/125333
Search -- https://master.php.net/manage/user-notes.php