
On 8/27/12 6:25 PM, J Baptist wrote:
Using ByteStrings and the C calls does indeed speed things up a bit, but not much. real 0m6.053suser 0m1.480ssys 0m4.550s For your interest:The original version (with Strings and openFile): http://hpaste.org/73803Faster (with Strings and c_open): http://hpaste.org/73802Even faster (with ByteStrings and c_open): http://hpaste.org/73801 The problem may be that even with ByteStrings, we are stuck using show, and thus Strings, at some point. Ideas?
Don't use Show. Show is only there for printing things at the REPL and has no place in performance-centric code. The bytestring-lexing[1] package has efficient functions for rendering integral numbers into ByteStrings[2]. And there are a number of other efficient ByteString renderers as well, such as blaze-builder[3]. [1] http://hackage.haskell.org/package/bytestring-lexing [2] Albeit, they haven't been hyper-aggressively optimized (cf., readDecimal), but that's because I haven't run into the need for doing so. If you can demonstrate a real need, I'm willing to spend some time on it. [3] http://hackage.haskell.org/package/blaze-builder -- Live well, ~wren