Thursday 16 February 2012

DEBUG vs RELEASE

Does it actually matter whether you release a debug build into production?

A few weeks ago I embarked on a personal project to create an arbitrary precision library for C#, I'm sure there are hundreds available, but I thought it would be a good small little project and if I ever finish it, I'll publish it in codeplex or something.

Since it's the easiest operation to implement, I started with addition, and was pretty happy with my implementation, but the question was, would it scale linearly?

The answer is yes, after some help from my friends, see graph below:



There is a clear linear scale but more, perhaps more importantly, is the difference between the DEBUG build and the RELEASE build. You can almost double the terms summed by simply compiling it as a RELEASE build, it's roughly 1/3 faster. To be sure, in real life, it probably won't make that much of a difference, but it is worth bearing in mind that performance will be affected if you deploy a DEBUG build to Production.

I repeated the same test, but this time using the addition operation to calculate a rather high term, 200000, of the Fibonacci series:


Again, there is quite a bit of difference between the RELEASE and DEBUG builds, unfortunately I lost the data for this image, so I cannot quantify the gain exactly, but from the graph it can be seen that it is roughly 1/3 faster.

Make sure that a debug build does not get into your production or performance test environment.

No comments:

Post a Comment