I use the following code to calculate the SHA1 of a file :
set stream = ##class(%Stream.FileBinary).%New()
do stream.LinkToFile(filename)
write$SYSTEM.Encryption.Base64Encode($SYSTEM.Encryption.SHA1HashStream(stream))This 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.
.png)
.png)
.png)
.png)
.jpg)
.png)

