Skip to main content
This is lesson 7 of 11 in this module Course 96% complete

Demo: Benchmarking Memory Copy

Premium Content

Sign in with your account or sign up to access this lesson.

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.