473,748 Members | 5,429 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Console.Writeli ne in release builds a performance issue ?

Hi

Can a lot of Console.Writeli ne commands cause a program to run slower ?

johan

Nov 23 '05 #1
5 5342
The short answer is I don't know. But why dont you try looping over 1
million times doing Console.Writeli ne and see how long it takes. If it
takes 1 second or less (dont run it under debug mode) then theres really
no point going round commenting out all the references in your code.

Instead, why not define a DEBUG symbol and only include it in debug
builds. eg
#if DEBUG
Console.Writeli ne("This is a debug only statement");

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Nov 23 '05 #2
I couldn't help myself...

DateTime start = DateTime.Now;
for(int i=0;i<1000000;i ++)
Console.WriteLi ne("hello there");

StreamWriter writer = new StreamWriter("t ime.txt");
string line = "time=" + (DateTime.Now.T icks-start.Ticks)/10000 +
"ms";
writer.WriteLin e(line);
writer.Close();

Takes about 500ms on my machine (2.8Ghz nothing special)

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Nov 23 '05 #3
An easier way rather than putting lots of #if DEBUG all over your code is to
use either the:

System.Diagnost ics.Debug.Write Line or
System.Diagnost ics.Trace.Write Line methods

When in debug mode both Trace and Debug will output, when in release only
trace will output, unless you remove the TRACE symbol from you compiler
options.

Hope that helps.
Mark R Dawson
http://www.markdawson.org


"vooose" wrote:
The short answer is I don't know. But why dont you try looping over 1
million times doing Console.Writeli ne and see how long it takes. If it
takes 1 second or less (dont run it under debug mode) then theres really
no point going round commenting out all the references in your code.

Instead, why not define a DEBUG symbol and only include it in debug
builds. eg
#if DEBUG
Console.Writeli ne("This is a debug only statement");

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***

Nov 23 '05 #4
Thanks

"Mark R. Dawson" <Ma*********@di scussions.micro soft.com> wrote in message
news:35******** *************** ***********@mic rosoft.com...
An easier way rather than putting lots of #if DEBUG all over your code is to use either the:

System.Diagnost ics.Debug.Write Line or
System.Diagnost ics.Trace.Write Line methods

When in debug mode both Trace and Debug will output, when in release only
trace will output, unless you remove the TRACE symbol from you compiler
options.

Hope that helps.
Mark R Dawson
http://www.markdawson.org


"vooose" wrote:
The short answer is I don't know. But why dont you try looping over 1
million times doing Console.Writeli ne and see how long it takes. If it
takes 1 second or less (dont run it under debug mode) then theres really
no point going round commenting out all the references in your code.

Instead, why not define a DEBUG symbol and only include it in debug
builds. eg
#if DEBUG
Console.Writeli ne("This is a debug only statement");

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***

Nov 23 '05 #5
Sagaert Johan wrote:
Can a lot of Console.Writeli ne commands cause a program to run slower


Compared to what? Not doing something will always be faster than doing
something.

--
Truth,
James Curran [erstwhile-MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
Nov 24 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
22035
by: Boba | last post by:
Hi, I'm programming a WinForm application. I would like to enter commands that will send output that will help me to locate bugs in the future. I know that there is a way to send output by using the Console.Write command. The question is how can I see the outputs in the client machine ? Is there a specific programm to do it or Can I use the prompt window ?
2
5950
by: Franco, Gustavo | last post by:
Hi, Console.WriteLine does something on Release mode? I have many of them in my application and I want to know if the performace could be affected, on debug mode I can see a big difference between having and not because I'm printing many of them on loops, etc. Now, in Release mode Console.Writeline has something like #if (!Release), send the string to something like "/dev/null" or it is executed internally
19
5905
by: Jeff S | last post by:
Whenever I execute any Console commands (Console.WriteLine "yada yada yada"), the console does not appear. It doesn't even flash by. I want to be able to use Console commands. Any ideas? I'm running VS.NET 2003 on XP pro/SP1.
2
4749
by: Steve | last post by:
I have created a console app that simply prints out a message a couple times, then exits, here is the code: <code> for(int i = 0; i < 10; i++) { System.Threading.Thread.Sleep(500); Console.WriteLine(String.Format("Sleeping...{0}", i)); } Console.WriteLine("Done!"); </code>
0
1024
by: Peteroid | last post by:
I use the Console for debug purposes, so I created my application as a Console project. I create my own custom Form class, so I don't want to use a winform project (unless I can disable the designer one). When it's time to demo, I don't want the Console to come up at all... There must be a way to remove or hide the Console (hopefully within a Console project). In 2003 I switched between two different 'main' calls in order to either have...
1
2041
by: John Wright | last post by:
I am running a console application that connects to an Access database (8 million rows) and converts it to a text file and then cleans and compacts the database. When it runs I get the following error: The CLR has been unable to transition from COM context 0x1a2008 to COM context 0x1a2178 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long...
2
1956
by: Wayne Sepega | last post by:
We are currently having an issue with one of our web applications. Some users receive an exception when using the app, but the method that has the error in the stack trace has a few places that could cause the error. So my question is, what are the CONS to deploying the PDB's that are built with the application if you build in release mode? Security? performance? anything else? Thanks
4
3034
by: =?Utf-8?B?UiBSZXllcw==?= | last post by:
does this command use a lot of resources? should i comment them all out before creating my .exe file? i use it a lot for debugging... or, does it not make much of a difference? thanks much
3
15519
by: Bob Johnson | last post by:
It is my understanding - and please correct me if I'm wrong - that when building a project in debug mode, I can deploy the .pdb file along with the ..exe and thereby have access to the specific line number of code that throws an exception. Specifically, I can have an error logging routine that, amongst other things parses the call stack and tells me the specific line of code that choked. It is also my understanding that if building in...
0
8987
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9534
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9316
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.