开发者

What are your techniques of optimizing your code in c++? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

What ar开发者_JAVA技巧e your techniques of optimizing your code in c++?


  1. Write code
  2. Profile code
  3. Tweak performance hot spots
  4. If still not fast enough, go to step 2


1) Write the cleanest and most straightforward code I can.
2) Use a modern compiler with optimized settings.
3) Be done.

Optional:
4) If I think something is noticeably slow, profile my application.
5) Use my profile results to find out what's slow, and fix it.
6) Make sure it's still as clean and straightforward as possible.
7) Be done.


The most important technique is not optimising until you know it's a bottleneck.


Follow coding standards. Have a look at http://sourcemaking.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜