Overhead associated with OutputDebugString in release build

后端 未结 8 1847
有刺的猬
有刺的猬 2020-12-15 05:26

Is there a significant overhead associated with calling OutputDebugString in release build?

相关标签:
8条回答
  • 2020-12-15 06:02

    Measured - 10M calls take about 50 seconds. I think it's significant overhead for unused functionality.

    Using a macro can help get rid of this in release build:

    #ifdef _DEBUG
        #define LOGMESSAGE( str ) OutputDebugString( str );
    #else
        #define LOGMESSAGE( str )
    #endif
    

    Not only removes the calls, but also the parameters evaluation and the text strings are entirely removed and you'll not see them in the binary file.

    0 讨论(0)
  • 2020-12-15 06:02

    I was curious about this topic so I did some research.

    I've posted the results, the source code and project files so that you can repeat the tests for your setup. Covers running a release mode app without anything monitoring OutputDebugString and then with Visual Studio 6, Visual Studio 2005 and Visual Studio 2010 monitoring OutputDebugString to see what differences in performance there are for each version of Visual Studio.

    Interesting results, Visual Studio 2010 processes OutputDebugString information up to 7x slower than Visual Studio 6.

    Full article here: Whats the cost of OutputDebugString?

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