[Haskell-cafe] haskell crypto is reaaaaaaaaaally slow

Stefan O'Rear stefanor at cox.net
Tue Jun 19 23:34:12 EDT 2007


On Wed, Jun 20, 2007 at 01:24:00PM +1000, Donald Bruce Stewart wrote:
> aeyakovenko:
> > $ time ./md5sum ./md5sum
> > [105,252,52,138,187,192,216,17,225,123,185,3,124,101,86,132]
> > 
> > real    0m4.790s
> > user    0m3.688s
> > sys     0m0.492s
> > 
> > $ time md5sum ./md5sum
> > 69fc348abbc0d811e17bb9037c655684  ./md5sum
> > 
> > real    0m0.023s
> > user    0m0.000s
> > sys     0m0.008s
> > 
> > this is my implementation using crypto
> > (http://www.haskell.org/crypto/).  Am I doing something wrong?
> > 
> > module Main where
> > 
> > import System
> > import qualified Data.Digest.MD5 as MD5
> > import qualified Data.ByteString as BS
> > 
> > main = do
> >   args <- getArgs
> >   dt <- BS.readFile $ head args
> >   putStrLn $ show $ MD5.hash . BS.unpack $ dt
>                ^^^^              ^^^^^^^^^
> 
>                                  not a good idea.
> 
> You need an MD5 over bytestrings, not [Word8].

Wouldn't deforestation have produced something within a factor of 4-ish
of optimal?

Stefan


More information about the Haskell-Cafe mailing list