note 45465 added to function.mt-rand

From: Date: Wed, 08 Sep 2004 11:08:38 +0000
Subject: note 45465 added to function.mt-rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-76219@lists.php.net to get a copy of this message
mt_rand is a better random method, BUT mt_rand() is NOT four time faster than rand() $> time echo "<?php \$i = 1000000; while(\$i--) { rand(0,10); } ?>" | php php 1.68s user 0.01s system 99% cpu 1.693 total $> time echo "<?php \$i = 1000000; while(\$i--) { mt_rand(0,10); } ?>" | php php 1.69s user 0.02s system 100% cpu 1.708 total time echo "<?php \$i = 1000000; while(\$i--) { rand(0,100000); } ?>" php 1.71s user 0.00s system 99% cpu 1.713 total time echo "<?php \$i = 1000000; while(\$i--) { mt_rand(0,100000); } ?>" | php php 1.72s user 0.02s system 100% cpu 1.726 total ---- Manual Page -- http://www.php.net/manual/en/function.mt-rand.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45465 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45465&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45465&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#76219) next »