On Friday 16 March 2007 21:29, David Brown wrote: > Ian Lynagh wrote: > > On Sun, Mar 11, 2007 at 08:18:44PM +0000, Dominic Steinitz wrote: > >> I have re-written the sha1 code so that it is (hopefully) easy to see > > that it > > >> faithfully implements the algorithm (see > >> http://www.itl.nist.gov/fipspubs/fip180-1.htm). Having got rid of the > > space > > >> leak, I have been trying to improve performance. > >> > >> Currently, the haskell code is 2 orders of magnitude slower than the > > sha1sum > > >> that ships with my linux. > > > > I don't know if this is useful to you, but darcs has some SHA1 code that > > IIRC is much closer to C's performance. It currently uses darcs' own > > FastPackedString library, but porting it to ByteString should be fairly > > easy. > > > > See SHA1.lhs in http://www.abridgegame.org/repos/darcs-unstable > > > > It might even be able to be made faster still by calling lower-level > > functions than {shift,rotate}{L,R} directly. > > I ended up deciding to call SHA1 routines out of openssl. For > applications where this is possible, it does very well, I got about > 2.5 times the speed out of it, compared to ordinary C implementations. > > But, since harchive spends most of its CPU computing SHA1 hashes (and > almost all of the rest in zlib), it is worth a complex binding there. > > Dave Ian, Dave,
Thanks. My goal is to have natural haskell code that's reasonably efficient. I don't have a problem to solve that needs an efficient implementation of SHA1. I'm going to try apfelmus' suggestions next and then (if I ever get yhc to build) start looking at what gets generated. Dominic. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe