reading text files
Tomasz Zielonka
t.zielonka at students.mimuw.edu.pl
Mon Oct 4 16:25:38 EDT 2004
On Mon, Oct 04, 2004 at 08:34:42PM +0200, Peter Simons wrote:
>
> hGetContents is fine, although you have to be aware that the
> function does not implement any timeouts. Meaning, if you
> don't receive the data you need, your program will hang.
>
> Whether your application is fast or not doesn't really
> depend on how you read the data, but on how you _process_
> it.
Simply counting the number of characters in input using
getContents can be 6 times slower than doing the same thing using
hGetArray (still doing unsafeRead for every character, even if
it's not necessary for this particular task).
So, hGetContents may not be the best solution if you care about
performance, at least in GHC 6.2.1.
Best regards,
Tom
--
.signature: Too many levels of symbolic links
More information about the Glasgow-haskell-users
mailing list