[Haskell-cafe] Slow IO?
Eugene Kirpichov
ekirpichov at gmail.com
Wed Sep 2 00:26:23 EDT 2009
2009/9/2 Steve <stevech1097 at yahoo.com.au>:
> 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
>
I've got a Centrino Duo 2000 (I'm on a notebook), Ubuntu 9.04 and ghc 6.10.2.
However, we have not set up on what exact input file we're using :)
I'm using one where it is written "10000000 3" and then 10000000 lines
of "999999999" follow.
Also, I wonder what one'd get if one compiled this program with jhc,
but I don't know whether jhc is able to compile Data.ByteString.
> Steve
>
>
--
Eugene Kirpichov
Web IR developer, market.yandex.ru
More information about the Haskell-Cafe
mailing list