[Haskell-cafe] Haskell version of ray tracer code is muchslowerthan the original ML

Philip Armstrong phil at kantaka.co.uk
Sat Jun 23 14:07:49 EDT 2007

On Sat, Jun 23, 2007 at 12:05:01PM +0100, Claus Reinke wrote:
>>>try making ray_sphere and intersect' local to intersect,
>>>then drop their constant ray parameter. saves me 25%.
>also try replacing that (foldl' intersect') with (foldr (flip intersect'))!

Thanks guys, this is exactly the kind of advice I was seeking.

OK, next question: Given that I'm using all the results from
intersect', why is the lazy version better than the strict one? Is ghc
managing to do some loop fusion?

>using a recent ghc head instead of ghc-6.6.1 also seems to
>make a drastic difference (wild guess, seeing the unroll 1000
>for ocaml: has there been a change to default unrolling in ghc?).

Um. I tried ghc head on the current version and it was about 15%
*slower* than 6.6.1

Perhaps it does better on the (slightly) optimised version?


http://www.kantaka.co.uk/ .oOo. public key: http://www.kantaka.co.uk/gpg.txt

More information about the Haskell-Cafe mailing list