loop performance bug
Lemmih
lemmih at gmail.com
Mon Mar 14 20:12:34 EST 2005
On Tue, 15 Mar 2005 02:06:06 +0100, Lemmih <lemmih at gmail.com> wrote:
> 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
A small update making the test more fair:
> test5 :: IO ()
> test5 = do
> (arr :: IOUArray Int Int) <- newArray_ (0,100*100-1)
> doFromTo 0 9999 $ \_ ->
> doFromTo 0 99 $ \y ->
> doFromTo 0 99 $ \x ->
> unsafeWrite arr (x*(y+1)) 0
I previously though that Bools were optimized away, guess I was wrong.
test5: 0.8s
--
Friendly,
Lemmih
More information about the Glasgow-haskell-bugs
mailing list