loop performance bug

Lemmih lemmih at gmail.com
Mon Mar 14 20:06:06 EST 2005


We can make it a little faster by not doing bound checks:

> test4 :: IO ()
> test4 = do
>   (arr :: IOUArray Int Bool) <- newArray_ (0,100*100-1)
>   doFromTo 0 9999 $ \_ ->
>     doFromTo 0 99 $ \y ->
>       doFromTo 0 99 $ \x ->
>         unsafeWrite arr (x*(y+1)) False

Timings (compiled with -O2):
test1: 12.6s
test2: 8.5s
test3: 1.9s
test4: 1.3s

-- 
Friendly,
  Lemmih



More information about the Glasgow-haskell-bugs mailing list