If I have WPF application and for debugging purposes there are messages that are being displayed on the console. Will this affect the performance of the application when its configured as a Windows Application and no console is being displayed?
The real bottleneck in Console.WriteLine() is in actually writing to the console. Which is really expensive, particularly when the console needs to be scrolled. There is also considerable overhead in the Visual Studio hosting process capturing the output when there is no console and displaying it in the Output window instead.
Neither of which play a role after you deploy your app. But yes, all the method calls are being made and strings are getting formatted, it only falls in the bit-bucket at the last possible moment when the Windows api function finds out there is no console.
If your app has acceptable perf now, when running in the Debug build, then don't worry about it. If you see less than stellar perf in the Release build without a debugger and you think that it might be caused by Console.WriteLine() then don't hesitate to Search+Replace it to Debug.Print().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With