title: When to use -O2 flag for gcc?
body: <p>If I use "-O2" flag, the performance improves, but the compilation time gets longer. </p>
  
  <p>How can I decide, whether to use it or not? </p>
  
  <p>Maybe O2 makes the most difference in some certain types of code (e.g. math calculations?), and I should use it only for those parts of the project?</p>
  
  <p>EDIT: I want to emphasize the fact that setting -O2 for all components of my project changes the total compilation time from 10 minutes to 30 minutes.</p>