[Haskell-cafe] Why is this so inefficient?
Bryan O'Sullivan
bos at serpentine.com
Tue Feb 5 15:21:03 EST 2008
Jefferson Heard wrote:
> I thought this was fairly straightforward, but where the marked line
> finishes in 0.31 seconds on my machine, the actual transpose takes
> more than 5 minutes. I know it must be possible to read data in
> haskell faster than this.
I took a look into this, writing a similar, but simpler, program. Half
of the runtime, and 2/3 of the allocation, is spent in ByteString's
split function. The remaining portions are spent in transposing the list.
COST CENTRE %time %alloc ticks bytes
split 66.7 65.1 56 120130000
xpose 31.0 32.8 26 60618031
read 1.2 2.0 1 3640229
lines 1.2 0.1 1 260002
I've attached two programs to demonstrate the problem. One creates a
sample speadsheet; the other transposes it.
I spent a little time trying to find a faster replacement for
ByteString.split, but no luck before I had to return to other things.
<b
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Transpose.hs
Type: text/x-haskell
Size: 490 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080205/3db0d1c1/Transpose.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GenSheet.hs
Type: text/x-haskell
Size: 341 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080205/3db0d1c1/GenSheet.bin
More information about the Haskell-Cafe
mailing list