[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] Is Haskell capable of matching C in string processin

Subject: Re: [Haskell-cafe] Is Haskell capable of matching C in string processing performance?
From: John Millikin
Date: Fri, 22 Jan 2010 09:45:37 -0800
There's no such thing as "cheating", though that particular code won't
work for my purposes because it assumes the output is merely a stream
of "null". Fine for the benchmark, but not extractable to the full

I wonder: is Handle known to be particularly slow? This code only has
to work on Linux and BSD, so if using (for example) a POSIX fd would
be much faster, it could bring the Haskell version much closer to C.

On Fri, Jan 22, 2010 at 07:30, Tom Nielsen <[email protected]> wrote:
>> It seems to me this indicates that the big expense here is the call into the 
>> I/O system.
> So let's make fewer I/O calls:
> import Control.Monad
> import qualified Data.ByteString.Char8 as S
> import System.IO
> null_str1 = S.concat $ take 1000 $ repeat $ S.pack "null"
> n1 = 5000000 `div` 1000
> main = withBinaryFile "out3.json" WriteMode $ \h -> do
> ÂhPutStr h "["
> ÂreplicateM_ n1 (S.hPutStr h null_str1)
> ÂhPutStr h "]"
> ---
> this is 10x faster. Whether this is cheating or not depends on what
> John actually wants to do.
> Tom
Haskell-Cafe mailing list
[email protected]

<Prev in Thread] Current Thread [Next in Thread>