In NetCore, MS added some new functions to copy memory, I want to know which is the best in performance.
Note: There is a similar answer for .NET Framework but NetCore has some drastical changes!
Cannot see any source code
Unsafe.CopyBlock
- memcpy ?Unsafe.CopyBlockUnaligned
- will omit compiler check for aligned memory ?
These looks to be using same methods internally.
Array.Copy
- userBuffer
class.Buffer.BlockCopy
- .NET Framework used memcpy, using memmove in Core.Buffer.MemoryCopy
- docs suggest its using unsafe pointers to copy 64bit word per op, internally memmove.
I have used https://source.dot.net/ to inspect NetCore source code.