codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php $iterations = 100000; // ============================ $i = $rand = $start = $randTime = 0; $start = microtime(TRUE); while ($i++ < $iterations) { $rand = rand(); } $randTime = microtime(TRUE) - $start; // ============================ $i = $rand = $start = $randTimeRange = 0; $start = microtime(TRUE); while (++$i < $iterations) { $rand = rand(0, 100000); } $randTimeRange = microtime(TRUE) - $start; // ============================ $i = $rand = $start = $mtRandTime = 0; $start = microtime(TRUE); while ($i++ < $iterations) { $rand = mt_rand(); } $mtRandTime = microtime(TRUE) - $start; // ============================ $i = $rand = $start = $mtRandTimeRange = 0; $start = microtime(TRUE); while (++$i < $iterations) { $rand = mt_rand(0, 100000); } $mtRandTimeRange = microtime(TRUE) - $start; // ============================ echo " Iterations: $iterations rand(): $randTime rand(0, 100000): $randTimeRange mt_rand(): $mtRandTime mt_rand(0, 100000): $mtRandTimeRange ";
Private
[
?
]
Run code
Submit