RANDOM() and RANDOM(FALSE) problem




Robert Dodier wrote:

>--- Raymond Toy  wrote:
>
>  
>
>>    Robert> The down side is that it's substantially slower than the
>>    Robert> unmodified mt19937. 
>>
>>I'm a bit surprised.  How did you compare the generation speed
>>between your version and the unmodified mt19937?  
>>    
>>
>
>Well, I did this:
>
>  (load "rand-mt19937.lisp")
>  (time (dotimes (i 1000000) (mt19937::random 123456)))
>
>and compared that to: (time (dotimes (i 1000000) (random 123456)))
>
>But perhaps I should have done this:
>
>  (compile-file "rand-mt19937.lisp")
>  (load "rand-mt19937.x86f")
>  (time (dotimes (i 1000000) (mt19937::random 123456)))
>
>That is MUCH faster. 
>

I'm not sure what system you are using, but if compilation is not done 
automatically on command lines,
you should consider this:
(defun test(n)(declare(fixnum n))(dotimes (i n)(....))
(compile 'test)
(time (test 1000000))

and also compare it with the empty loop.



>
>The built-in CMUCL RANDOM runs about 0.1 microseconds per
>random number this way. MT19937::RANDOM runs about 0.3 microseconds.
>
>Of course speed will vary by Lisp implementation and 
>hardware platform. 
>
>Incidentally, Clisp barfs on (compile-file "rand-mt19937.lisp") --
>it complains "cannot redefine built-in class #RANDOM-STATE>", although (load "rand-mt19937.lisp") is OK.
>Any idea about how to make Clisp compile happily? 
>
>For what it's worth,
>Robert Dodier
>
>
>