Optimizing member variable order in C++

前端 未结 10 684
长发绾君心
长发绾君心 2020-12-04 07:18

I was reading a blog post by a game coder for Introversion and he is busily trying to squeeze every CPU tick he can out of the code. One trick he mentions off-hand is to

10条回答
  •  遥遥无期
    2020-12-04 07:57

    Depending on the type of program you're running this advice may result in increased performance or it may slow things down drastically.

    Doing this in a multi-threaded program means you're going to increase the chances of 'false-sharing'.

    Check out Herb Sutters articles on the subject here

    I've said it before and I'll keep saying it. The only real way to get a real performance increase is to measure your code, and use tools to identify the real bottle neck instead of arbitrarily changing stuff in your code base.

提交回复
热议问题