[Haskell-cafe] Haskell performance question

Bulat Ziganshin bulat.ziganshin at gmail.com
Thu Nov 8 16:29:21 EST 2007

Hello Don,

Thursday, November 8, 2007, 10:53:28 PM, you wrote:

>>    a <- newArray (0,n-1) 1.0 :: IO (IOUArray Int Double)
>>    forM_ [0..n-2] $ \i -> do { x <- readArray a i; y <- readArray a
>> (i+1); writeArray a (i+1) (x+y) }

oh, i was stupid. obviously, first thing you need to do is to use
unsafeRead/unsafeWrite operations. i'm wonder how this code is only
20x slower than C version, may be you need to use gcc -O3 -funroll-loops
and gcc3 (because gcc4 becomes slower)

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list