Laziness (was: [Haskell-cafe] Performance problem with random numbers)

ntupel ntupel at
Mon Oct 15 17:28:44 EDT 2007

On Mon, 2007-10-15 at 10:48 -0400, David Roundy wrote:
> I have no idea if this example will help your actual code, but it
> illustrates that at least in this example, it's pretty easy to gain an
> order of magnitude in speed.  (That "func" is a weird function, by the
> way.)

Thanks for your reply David,

Unfortunately my original problem was that System.Random.{random,
randomR} is used instead of all these weird test functions that I came
up with during experimentation. And I can't force anything inside StdGen
so I see no way of speeding up the original program sans replacing the
random number generator itself. When I did that I became about 4 times
faster than with System.Random but still an order of magnitude slower
than for instance by using the Java implementation (and I can confirm
that (^) is *very* expensive in this context).

Many thanks again,

More information about the Haskell-Cafe mailing list