I even tested with updating a progress bar in a window and it was still faster...
Could this be checked on linux/mac by some folks (and windows) to see if is universally faster? I tested winxp,2003,7 both 32 and 64 bit os's; ranging on 7 year old single core machines to brand new quad core system.
It may have been my test files, which were just random files I grabbed off the server...
Code: Select all
Global gnChunkSize=(1024 * 32) ; 32 seemed to be more universally usable; experiment at will.
; there is a 'sweet spot' -- it becomes slower if too small or too big of a buffer is used.
Procedure.s iMD5FileFingerprint( cFile.s )
Protected cHash.s, nBytes, hFile, *pDataChunk, hMD5
Shared gnChunkSize
If FileSize(cFile)>-1
hFile = ReadFile(#PB_Any, cFile, #PB_File_SharedRead)
If hfile
FileBuffersSize(hFile, gnChunkSize )
*pDataChunk = AllocateMemory( gnChunkSize )
If *pDataChunk
hMD5 = ExamineMD5Fingerprint(#PB_Any)
If hMD5
While Not Eof(hFile)
; You could update a progress bar...
nBytes = ReadData(hFile, *p, gnChunkSize)
NextFingerprint(hMD5, *p, nBytes)
Wend
cHash = FinishFingerprint(hMD5)
Else
Debug "Failed to init md5"
EndIf
FreeMemory(*pDataChunk)
Else
Debug "Failed to allocate "+Str(gnChunkSize)+" bytes of memory"
EndIf
CloseFile(hFile)
Else
Debug "Failed to openf ile"
EndIf
Else
Debug "File does Not exist"
EndIf
ProcedureReturn cHash
EndProcedure