How is Array.Copy implemented in C#?

后端 未结 2 623
一整个雨季
一整个雨季 2020-12-05 20:17

I tried to look at the implementation of Array.Copy in C# with ILSpy but it didn\'t show me the implementation itself.

I wrote a simple benchmark, Array

2条回答
  •  情书的邮戳
    2020-12-05 20:35

    Same techniques used to write a fast memcpy function:

    • loop unrolling
    • transfer of aligned data in large chunks (often using SIMD)
    • CPU caching hints (SIMD helps here as well)

    See also:

    • Very fast memcpy for image processing?
    • How to increase performance of memcpy
    • does rewriting memcpy/memcmp/... with SIMD instructions make sense

提交回复
热议问题