]> git.mxchange.org Git - core.git/blobdiff - application/tests/rand.php
Continued:
[core.git] / application / tests / rand.php
diff --git a/application/tests/rand.php b/application/tests/rand.php
new file mode 100644 (file)
index 0000000..ddd36e6
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+$rands = array();
+$max_iter = 500000;
+$max_rand = 200000;
+
+print 'max_iter=' . $max_iter . ',max_rand=' . $max_rand . PHP_EOL;
+
+for ($idx = 0; $idx < $max_iter; $idx++) {
+       $number = mt_rand(0, $max_rand);
+       if (isset($rands['mt_rand'][$number])) {
+               $rands['mt_rand'][$number]++;
+       } else {
+               $rands['mt_rand'][$number] = 1;
+       }
+
+       $number = rand(0, $max_rand);
+       if (isset($rands['rand'][$number])) {
+               $rands['rand'][$number]++;
+       } else {
+               $rands['rand'][$number] = 1;
+       }
+}
+
+print 'mt_rand=' . count($rands['mt_rand']) . PHP_EOL;
+print 'rand=' . count($rands['rand']) . PHP_EOL;