[Haskell-cafe] Help needed for converting IOArray to ByteString

Ketil Malde ketil at malde.org
Tue Feb 8 11:23:08 CET 2011

C K Kashyap <ckkashyap at gmail.com> writes:

> I am currently using a list of tuples - [(Int,Int,Int)] to represent an
> image buffer.
> Looks like this is pretty slow, 

Unsurprisingly, as there's a huge space overhead, and (depending on
usage, but probably even worse) linear access time.

> I wonder if working with [Word8] will also suffer from performance hit?

If the only thing you use [Word8] for is converting between arrays (for
image processing) and bytestrings (for IO), it is an O(n) cost added to
an already O(n) operation, so it's probably liveable.  

The intermediate list might be optimized away, and in any case, your
program might still be limited by disk bandwidth, so if you're lucky,
it boils down to a matter of using 20% or 40% CPU when doing file IO.

If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell-Cafe mailing list