How to make MSVC debug builds run faster

后端 未结 8 2059
日久生厌
日久生厌 2020-12-31 08:54

We have a large C++ application, which sometimes we need to run as a debug build in order to investigate bugs. The debug build is much much slower than the release build, t

相关标签:
8条回答
  • 2020-12-31 09:51

    We turned off Iterator debugging with the preprocessor symbols:

    _HAS_ITERATOR_DEBUGGING=0
    _SCL_SECURE=0
    

    It helped a bit, but was still not as fast as we'd like. We also ended up making our debug build more release-like by defining NDEBUG instead of _DEBUG. There were a couple other options that we changed too, but I'm not remembering them.

    Its unfortunate that we needed to do all this, but our application has a certain amount of work needed to be done every 50ms or its unusable. VS2008 out of the box would give us ~60ms times for debug and ~6ms times for release. With the tweaks mentioned above we could get debug down to ~20ms or so, which is at least usable.

    0 讨论(0)
  • 2020-12-31 09:52

    Use #pragma optimize("", off) at the top of selected files that you want to debug in release. This gives better stack trace/variable view.

    Works well if it's only a few files you need to chase the bug in.

    0 讨论(0)
提交回复
热议问题