How come my array index is faster than pointer

后端 未结 10 622
青春惊慌失措
青春惊慌失措 2020-12-17 16:58

Why the array index is faster than pointer? Isn\'t pointer supposed to be faster than array index?

** i used time.h clock_t to tested two functions, each loop 2 mil

10条回答
  •  爱一瞬间的悲伤
    2020-12-17 17:01

    I would suggest running each loop 200 million times, and then run each loop 10 times, and take the fastest measurement. That will factor out effects from OS scheduling and so on.

    I would then suggest you disassemble the code for each loop.

提交回复
热议问题