Global Variables performance effect (c, c++)

后端 未结 4 646
半阙折子戏
半阙折子戏 2021-02-05 08:24

I\'m currently developing a very fast algorithm, with one part of it being an extremely fast scanner and statistics function. In this quest, i\'m after any performance benefit.

4条回答
  •  抹茶落季
    2021-02-05 08:48

    Creating local variables can be literally free if they are POD types. You likely are overflowing a cache line with too many stack variables or other similar alignment-based causes which are very specific to your piece of code. I usually find that non-local variables significantly decrease performance.

提交回复
热议问题