Work Results

Followup: PHP: rand() vs. mt_rand()
My past comparison of rand() and mt_rand() only compared the speed, and I saw very little difference. This time I'll compare how truly random the numbers each function produces are. The code used to test this is:... mt_rand(0,512), mt_rand(0,512),
... mt_rand(0,255), mt_rand(0,255), mt_rand(0,255), mt_rand(0,127)
... imagepng($img,"mt_rand.png");
...mt_rand()
...So, if your code relies on random numbers, and you plan on using it on multiple operating systems, mt_rand() appears to be the way to go.

PHP: rand() vs. mt_rand()
The documentation for mt_rand() says that it produces numbers four times faster than the standard rand(). So, being that I use random numbers in my code often, I decided to test this....mt_rand();
...echo "{$max} random numbers generated in {$time} seconds using mt_rand();<br/>";
...On my laptop running a slightly outdated version of PHP 4.4 (around 4.4.0 if I remember correctly), the results were not as I expected. Most of the time, rand() was faster than mt_rand() by about 0.02 seconds. Of course, this isn't a big performance difference, but it's not the four times faster that was promised.
...100000 random numbers generated in 0.140385866165 seconds using mt_rand();
...100000 random numbers generated in 0.11861705780029 seconds using mt_rand();
...So, despite the PHP documentation, rand() and mt_rand() are about the same speed, rand is just slightly faster.
