I use the following code to calculate the SHA1 of a file :
set##class%Stream.FileBinaryThis code is called thousands of time and performance is critical. I have tried to code same logic in another language (which is lower level) and it's almost twice as fast. It's unclear why so I started investigating.
Using Process Monitor, it shows that files are read in chunks of 1024 bytes (1K) which is suboptimal. Reading a file of 1MB while require 1024 file system calls. Usually bigger buffer is used (eg : 4096 or 81920).
.png)
The SHA1HashStream() function is implemented this way :
160stream.
.png)
.png)
.png)
.jpg)
.png)

