[Haskell-cafe] Re: Is Haskell capable of matching C in string
processing performance?
John Lato
jwlato at gmail.com
Fri Jan 22 10:15:20 EST 2010
> From: Heinrich Apfelmus <apfelmus at quantentunnel.de>
> Don Stewart wrote:
>> jmillikin:
>>> Here's the fastest Haskell version I could come up with. It discards
>>> all error handling, validation, and correctness in the name of
>>> performance, but still can't get anywhere near C:
>>> http://hpaste.org/fastcgi/hpaste.fcgi/view?id=16423
>>
>> Thanks for posting the code.
>>
>> You're not using bytestrings??
>>
>> They were invented to deal with the problem of [Char] being a poor
>> structure for large scale string processing, and you should have no
>> problem getting C-like string performance.
>>
>> http://www.cse.unsw.edu.au/~dons/papers/CSL06.html
>
> In my limited experience, ByteStrings are great for reading data, but
> not that good for writing data that is being generated on the fly. For
> writing, good old difference lists or the Builder monoid / Put monad
> from Data.Binary seem to be best.
>
If find that this is particularly true if you don't know the length of
data to write in advance because it involves lots of new allocations
and copying. Using Builder/Put is definitely a better approach.
Out of curiousity, has anyone ever tried implementing a
LinkedListString in C to check what its performance would be? I
expect it would be pretty poor compared to standard strings.
Cheers,
John
More information about the Haskell-Cafe
mailing list