
Hello Haskell-cafe, i have analyzed performance of various sum-file implementations (see http://shootout.alioth.debian.org/debian/benchmark.php?test=sumcol&lang=all ) first, one-liner implementation (attached as b.hs) works about 500 seconds on my cpu. it can be made 10x faster just by using it's own 'read' procedure (c.hs). this tells us that current 'read' implementation in GHC is VERY SLOW. next step to make things go faster you can see at http://shootout.alioth.debian.org/debian/benchmark.php?test=sumcol&lang=ghc&id=4 - now it's the fastest GHC entry on this test. speedup is a result of throwing away all the lines/map/read/sum individual procedures and writing entire algorithm over the plain stream of Chars. this allows us to omit all the construction/deconstruction of lazy boxes, so this program works about 10 seconds on my box. now the main problem is getContents itself, which uses about 70% of total time, because it requires to construct/deconstruct lazy box for each Char read. Using Streams library, we can omit this work and use straightforward imperative code (h.hs). this program works 4 times faster (2.8 seconds) than faster Haskell variant, what should be about 1.5 times faster than today's fastest (D Digital Mars) entry in this test i think that close speed can be also obtained by using line-oriented I/O in Streams+ByteString combination and then applying some "readInt :: ByteString -> Int" conversion while compiling under GHC 6.5 -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com