The real bottleneck in Console.WriteLine () is actually written to the console. Which is really expensive, especially when you need to scroll through the console. In addition, there is significant overhead during the hosting process of Visual Studio, as a result of which there is no output when the console is not displayed and is displayed in the output window.
None of them matter after deploying your application. But yes, all method calls are made and the lines are formatted, they only get into the bit bucket at the last possible moment when the Windows api function detects that the console is missing.
If your application now has acceptable performance when running in the Debug assembly, do not worry about it. If you see less than the stellar perf in the Release assembly without a debugger, and you think this might be caused by Console.WriteLine (), feel free to look for + replace it with Debug.Print ().
Hans passant
source share