From: Tomas Brixi Date: 2002-02-24T04:32:04+09:00 Subject: Digest classes performance Hello, I have have done some test (especially) with Digest classes on MS Windows. Due to __very poooooor__ performance of mswin version I have run the same test with mingw and cygwin ruby version and also with python. The following are the speed results: SHA1 0.296 MB/s ruby 1.66 mswin/mingw * 18.041 MB/s activestate python 2.1 12.797 MB/s ruby 1.65 cygwin - by pragmatic programmers MD5 0.298 MB/s ruby 1.66 mswin/mingw * 22.158 MB/s activestate python 2.1 15.433 MB/s ruby 1.65 cygwin - by pragmatic programmers * - mswin version - 1.66 by pragmatic programmers - mingw version - 1.66 from http://www.ruby-lang.org/ These two ruby builds performs almost the same. Tested on CPU: AMD Duron 1GHz HDD: STSeagate Baracuda IV - 40GB Windows XP and Windows 2000 The absolute numbers from the results are not so important as the fact that python significantly outperforms ruby :-( The digest functions are written in C and so the performance should be quite well. Cygwin version is still usable but what about mswin/mingw? Is it caused by poor io performance or bad memory management under mswin or anything else? Regards Tom These are the used functions ---- ruby source ---- def FileHash( fName ) hash = Digest::SHA1.new if not FileTest.file?( fName ) return "" end inF = File.new( fName, "rb" ) bytesRead = 0 bytesTotal = File.size( fName ) while true buf = inF.read( 32768 ) if buf == nil break end hash.update( buf ) bytesRead += buf.length if fName.length > 40 fName = fName[0..16] + "~~~~~" + fName[-16..-1] end $stdout.write( "\r%-40s : %d of %d" % [ fName, bytesRead, bytesTotal ] ) end return hash.hexdigest end -------- ---- python source ---- def FileHash( fName ): if not os.path.isfile( fName ): return "" dig = sha.sha() inF = open( fName, "rb" ) bytesRead = 0 bytesTotal = os.path.getsize( fName ) while 1: buf = inF.read( 32768 ) if buf == "": break dig.update( buf ) bytesRead = bytesRead + len( buf ) sys.stdout.write( "\r%s : %d of %d" % ( fName, bytesRead, bytesTotal ) ) inF.close() return dig.hexdigest() -------- __________________________________________________ Do You Yahoo!? Yahoo! Sports - Coverage of the 2002 Olympic Games http://sports.yahoo.com