[Haskell-cafe] Re: Are there performant mutable Arrays in Haskell?

Achim Schneider barsoap at web.de
Tue Mar 24 08:40:53 EDT 2009

"Brettschneider, Matthias" <Brettschneider at hs-albsig.de> wrote:

> Thx for your hints, I played around with them and the performance
> gets slightly better. But the major boost is still missing :) 
> I noticed, that one real bottleneck seems to be the conversion of the
> array back into a list. The interesting part is, if I use the elems
> function (Data.Array.Base) the performance is about 4x better then
> with my own function. So I thought, I write my own version of elems,
> (that just converts a part of the array to a list) and I fall back
> into the same performance as my first approach. 
> To make a long story short, here is the library code: 
> elems arr = case bounds arr of
>       (_l, _u) -> [unsafeAt arr i | i <- [0 .. numElements arr - 1]
> And my version:
> boundedElems arr = case bounds arr of
>       (_l, _u) -> [unsafeAt arr i | i <- [1737 .. 1752]]
> Is there a reason, why the library version is 4 times faster, than
> mine?
Uhhhmmm... I've got no idea. But as the list is constructed lazily, you
shouldn't expect a real speedup by being lazy manually, anyway. You
might want to try the stream-fusion list implementation of lists, or
get rid of lists, alltogether.

(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.

More information about the Haskell-Cafe mailing list