2

I have an sln file for compiling c source code. when I compile that in VS2008 in release mode it takes around 4 minutes to compile the code. But in debug mode it take only 1 minute to compile the code. I didn't understand the difference in Release mode and debug mode.

Can anyone help me in this?

unknown
  • 643
  • 4
  • 15
  • 38
  • [Possible duplicate](http://stackoverflow.com/questions/933739/what-is-the-difference-between-release-and-debug-modes-in-visual-studio) – Dayal rai Aug 05 '13 at 12:58
  • 1
    [Optimizing compiler](https://en.wikipedia.org/wiki/Optimizing_compiler) gonna [optimize.](http://www.compileroptimizations.com/) – jrok Aug 05 '13 at 12:58
  • Are your timings measured against a Rebuild Solution or just on Build Solution? – Steve Aug 05 '13 at 12:59
  • Hi Steve, I measure the timing against the build solution only. when I do re-build also the same difference reflected. – unknown Aug 05 '13 at 14:27

3 Answers3

4

The optimizer is turned on by default in the Release configuration. Yes, it needs time to do its job. The linker is also not doing incremental links anymore, that can make a big difference.

You never really care about this, release builds are something you do when you're done or leave up to a build server.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
3

When building in debug mode, all extra work the compiler does is adding debug information (to simplify, basically a table of all symbols), this is very simple and goes fast. When building in release mode, the compiler does lots of optimizations, and those can be quite time consuming if the code is non-trivial.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
2

In release mode, the compiler spends much more effort working out optimisations - this is can be quite time-consuming, because it does similar things to a sudoku solver or chess engine - it tries a lot of different options to try to find the best one in this particular case.

Mats Petersson
  • 126,704
  • 14
  • 140
  • 227