Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Release vs Debug Build Times

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?

like image 907
Agnel Kurian Avatar asked Mar 24 '09 15:03

Agnel Kurian


2 Answers

Well, there are a number of variables that could affect things. Here are some reasons Debug could be faster:

  • Usually Debug mode does a lot less optimizations, as those can mess up the mapping between instructions and lines of code. So, the compiler is doing less work there.
  • Even if a full debug build is slower, Debug builds happen a lot more often and can usually take advantage of incremental builds a lot more than Release build can. So fairly often a Debug build doesn't have to do nearly as much work as a Release build would.
like image 192
Herms Avatar answered Oct 06 '22 23:10

Herms


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.

like image 36
Vatine Avatar answered Oct 06 '22 23:10

Vatine