>>>>> "Derek" == Derek Elkins <[EMAIL PROTECTED]> writes:

    Derek> ....

    Derek> Except that I would probably mapM_ over a list of chunks, I don't
    Derek> see what the problem is with your second version of the code is.

The second version allocates memory like crazy, so much that the
pokeByteOff and castCharToCChar version becomes twice roughly twice as
fast. Here are some figures [all compiled with -O2, otherwise version
c looses badly]: 

s - hash in one go
a - chunks of 512 characters
c - byte-wise

[on 51MB String]
Main a : 58.730u 1.440s 1:00.13 100.0%   0+0k 0+0io 182pf+0w
Main c : 29.370u 0.740s 0:30.07 100.1%   0+0k 0+0io 182pf+0w
[on 32MB String]
Main a : 37.500u 1.100s 0:38.58 100.0%   0+0k 0+0io 182pf+0w
Main c : 18.790u 0.510s 0:19.43 99.3%    0+0k 0+0io 182pf+0w
[on 500k String]
Main s : 0.560u 0.120s 0:00.66 103.0%    0+0k 0+0io 182pf+0w
Main a : 0.610u 0.010s 0:00.59 105.0%    0+0k 0+0io 182pf+0w
Main c : 0.290u 0.000s 0:00.27 107.4%    0+0k 0+0io 182pf+0w

So the generally most efficient seems to be to use c, but I suspect
that further gains would be possible if this variant were implemented
at a lower level. Hence the proposal for newCStringPart.

-Peter
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to