Demo: Benchmarking Memory Copy
We run a memory copy benchmark and demonstrate that Array.CopyTo is much faster than the code that uses a manual loop. The lesson explains that CopyTo emits the undocumented IL memcpy instruction, allowing the JIT compiler to generate CPU-level block-copy instructions, and concludes that CopyTo should always be preferred over hand-written copy loops.
Previous Module
Pointers in C#
This Module
Advanced Performance Optimizations