From: Kirk Haines Date: 2005-10-14T02:03:44+09:00 Subject: Re: ANN: Crypt::ISAAC 0.9.1 released On Thursday 13 October 2005 10:50 am, Daniel Berger wrote: > I got some improvement when I replaced "read" with "sysread" in ISAAC.rb. > Here's a little benchmark script I wrote: I'll make that change. > bm do |x| > x.report("rand"){ > MAX.times{ Crypt::ISAAC.new(true) } > } > > x.report("/dev"){ > MAX.times{ Crypt::ISAAC.new(false) } > } > end The default is true, which means to use the nonblocking entropy source (/dev/urandom), and while false tells it to use /dev/random. It only uses rand() if it can't find the /dev/urandom (or /dev/random if told to use that). So your timings that you have labeled "rand" are using /dev/urandom, and the one labeld "/dev" is using /dev/random. > # Using read > > >ruby bench_isaac.rb > > user system total real > rand 6.290000 0.410000 6.700000 ( 6.928163) > /dev 6.490000 9.640000 16.130000 ( 23.197032) > > # Using sysread > > >ruby bench_isaac.rb > > user system total real > rand 6.340000 0.550000 6.890000 ( 7.148228) > /dev 6.560000 3.050000 9.610000 ( 9.976435) I'm surprised it was that fast, actually. On my boxes, I had FAR less entropy in /dev/random available to me. I actually thought that something was wrong with my code the first time I tested it, it was so slow. :) Thanks for the feedback, Kirk Haines