[Haskell-cafe] Data.ByteStream.Char8.words performance

Dino Morelli dino at ui3.info
Fri Mar 30 21:10:30 EDT 2007


On Fri, 30 Mar 2007, Jeremy Shaw wrote:

> Hello,
>
> Did you compile with -O2 ? That makes a huge difference when using ByteString.
>
> j.
>

Ah, that was exactly it. I feel silly.


> module Main where
> 
> import qualified Data.ByteString.Char8 as B
> 
> main = do
>    content <- B.readFile "test-text-file"
>    let l = length . B.words $ content
>    print l


$ ghc -O2 count-b.hs
$ time ./a.out
174372

real    0m0.198s
user    0m0.136s
sys     0m0.012s


Much faster. Thank you!


dino-


More information about the Haskell-Cafe mailing list