Reputation: 59466
I have always believed that Debug builds are slower than Release builds since the compiler needs to additionally generate debugger information. I was recently surprised to hear one of my colleagues saying that release builds usually take more time. (I believe that it is only because of incremental linking/compiling).
In general, which of the two is faster?
Upvotes: 7
Views: 4081
Reputation: 19413
The primary reason release builds will be faster is that the compiler does a lot of optimization on them. For example, it may unroll loops, remove unnecessary variables, and inline functions. Optimization is not a trivial task and takes a lot of computing power, thus slowing down the build.
Most compilers will let you turn off optimization on release builds. Try this. Your build times will shrink. You can also turn on optimization on debug builds and see your build times climb.
Upvotes: 0
Reputation: 21258
On the whole, I'd expect that a debug build will be faster to build, but slower to run and a release build to take longer to build, but the end result would run faster.
This is down to the release buid probably having more aggressive optimisations and these can interfer with debuggability. Also, some larger-scale optimisations do take a long time. The time to insert debug information in the object files is small enough to be ignorable, it probably takes less time than reading the source code off disk in the first place.
Upvotes: 2
Reputation: 9552
The debug builds are usually faster because there is no optimization being done (which is very common in release builds).
You can opt to not generate debugging symbols with your executable and no optimization too, but that would be strange for a release build. Though it would build faster I think.
The main difference between Debug and Release is that Debug is meant for debugging (so includes debugging symbols) and Release is meant to run faster, so you use strong optimization
Upvotes: 0
Reputation: 38798
Well, there are a number of variables that could affect things. Here are some reasons Debug could be faster:
Upvotes: 16
Reputation: 14513
Just a guess but I would assume that the release build would take longer in most cases because of optimization.
Upvotes: 0