Ben Chuanlong Du's Blog

And let it direct your passion with reason.

Performance Tips for C++

Performance

  1. If there is some block of useless code, the compile is smart enough to ignore it and thus speed up the program.

  2. Use the option -O2 to generate optimized code when you are ready to publish your code.

  3. Define variables only when needed to avoid the overhead of creating …