Why is memmove faster than memcpy?

后端 未结 4 761
灰色年华
灰色年华 2020-12-12 15:01

I am investigating performance hotspots in an application which spends 50% of its time in memmove(3). The application inserts millions of 4-byte integers into sorted arrays,

4条回答
  •  孤城傲影
    2020-12-12 15:16

    "memcpy is more efficient than memmove." In your case, you most probably are not doing the exact same thing while you run the two functions.

    In general, USE memmove only if you have to. USE it when there is a very reasonable chance that the source and destination regions are over-lapping.

    Reference: https://www.youtube.com/watch?v=Yr1YnOVG-4g Dr. Jerry Cain, (Stanford Intro Systems Lecture - 7) Time: 36:00

提交回复
热议问题