[Haskell-cafe] Slow IO?

Steve stevech1097 at yahoo.com.au
Tue Sep 1 23:55:41 EDT 2009


On Tue, 2009-09-01 at 08:45 +0400, Eugene Kirpichov wrote:
> Hm, on my machine Don's code has exactly the same performance my code above.
That's strange.

> Also, replacing the 'test' and 'parse' functions with this one
> 
> add :: Int -> Int -> S.ByteString -> Int
> add k i s = fst $ S.foldl' f (i, 0) s
>   where f (!i, !n) '\n' | n`divisibleBy`k = (i+1, 0)
>                         | otherwise       = (i,   0)
>         f (!i, !n) w  = (i, 10*n+ord w-ord '0')
> 
> increases performance by another 15% (0.675s vs 0.790s)

On my system I get a 50% slowdown using this add function!

I guess is just shows that benchmarking code on one single
CPU/memory/OS/ghc combination does not give results that apply widely.
I'm using:
AMD Athlon X2 4800
2GB memory
Linux (Fedora 11, 64-bit version)
ghc 6.10.3

Steve



More information about the Haskell-Cafe mailing list