I see one of the possible ways to speed up this process: calculate the MD5 of the source file , and execute a copy, not before it. This will reduce the number of times you need to read the entire file from 3 (hash of source code, copy, hash of destination) to 2 (copy, hash of destination).
The disadvantage of all this is that you have to write your own copy code (and not just rely on System.IO.File.Copy), and there is an unnecessary chance that this will turn out to be slower in the end than a three-step process.
Other than that, I donβt think that much can be done here, since the whole process is connected with the design I / O interface. You spend most of your time reading and writing a file, and even at a speed of 100 MB / s (a respectable I / O speed for your typical SATA drive) you will at best do about 5.8 GB / min.
With a modern processor, the overhead of computing MD5 (or anything else) doesn't really affect things, so speeding it up won't improve your overall throughput. Crypto accelerators, in particular, will not help you here, because if the driver implementation is very effective, they will add additional overhead due to the context switches needed to supply data to an external card, than they will save.
What you want to improve is I / O speed. The .NET framework is already quite effective when it comes to this (using good-sized buffers, overlapping I / O, etc.), but it is possible that an optimized application for native Windows will work better here. My tip: google around for a few of your own MD5 calculators and see how they compare to your current .NET implementation. If the difference in the speed of computing hashes is> 10%, you should switch to using an external application.
source share