What are your techniques of optimizing your code in c++? [closed]
What ar开发者_JAVA技巧e your techniques of optimizing your code in c++?
- Write code
- Profile code
- Tweak performance hot spots
- 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/
精彩评论