Re: C++ really made my day!
On 21/10/09 01:47, Dave Harris wrote:
0xCDCDCDCD@gmx.at (Martin B.) wrote (abridged):
We did some tests on our app (Windows GUI + lots background
multithreading& data processing) and when we activated the
optimizations in VS the processor % impact was about factor 2, 2.5
smaller.
Compiling for Release changed the original poster's time from 75 to 2
seconds, which is a factor of 30 or so.
A lot of the standard template library, including std::vector, more or
less assumes inlining. It uses a lot of layers of trivial functions that
just disappear in a Release build. In a Debug build, VC++ will normally
not inline anything at all, no matter how trivial, so the compiled code
matches the source more closely. Hence std::vector et al tends to be
disproportionately slow in Debug builds.
The reason M$VC++ STL is ridiculously slow in debug mode is not inlining
(or rather lack of it). It is debug iterators and debug checks which
make it crawl.
Interestingly enough, debug iterators are supposed to be controlled by
_HAS_ITERATOR_DEBUGGING macro. However, the debug mode C++ run-time is
compiled with _HAS_ITERATOR_DEBUGGING=1. This means that if user code is
compiled in debug mode with _HAS_ITERATOR_DEBUGGING=0 that silently
breaks binary compatibility of the user code and the C++ run-time. The
application crashes at run-time.
--
Max
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]