473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

YES/NO: Console.WriteLine use a lot of resources?

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

May 23 '07 #1
4 3016

Wrap your code into a method:
public static void MyConsoleWrite ( string msg )
{
Console.Writeline ( msg ) ;
}
Then you only have 1 place to comment out the code.
public static void MyConsoleWrite ( string msg )
{
//Console.Writeline ( msg ) ;
}
//this is the non debug version
public static void MyConsoleWrite ( string msg , bool alwaysWrite )
{

if ( alwaysWrite )
{

Console.Writeline ( msg ) ;

}
}

//this is the non debug version
public static void MyConsoleWrite ( string msg , bool alwaysWrite )
{

// if ( alwaysWrite ) //aka ignore the bool flag and always write it
out
//{

Console.Writeline ( msg ) ;

//}
}


"R Reyes" <R Re***@discussions.microsoft.comwrote in message
news:FD**********************************@microsof t.com...
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

May 23 '07 #2
If you are using it for debugging, and you are providing a release
version, then it's not really a resource issue, but rather, you have code
which is not appropriate for a release version.

That being said, WriteLine doesn't consume resources, but if you call it
a significant number of times, you are going to impact the performance of
your system.

Instead of using Console.WriteLine for debugging, why not use the static
WriteLine methods on the Debug class? You can attach listeners to the Debug
class and have the output sent anywhere you wish (including the console) and
in your release app, the calls won't be made.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"R Reyes" <R Re***@discussions.microsoft.comwrote in message
news:FD**********************************@microsof t.com...
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

May 23 '07 #3
No. But it does perform I/O blocking as there's a lot of synchronousity with
command line I/O. It shouldn't slow down the kernel from multiprocessing but
it will likely slow down your own app just to pump text to your console
window.

Jon

"R Reyes" <R Re***@discussions.microsoft.comwrote in message
news:FD**********************************@microsof t.com...
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

May 23 '07 #4
R Reyes wrote:
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?
Look at a real logging framework like log4net.

Arne
May 26 '07 #5

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

Similar topics

1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
7
by: shawnk | last post by:
Hello Everyone How do you format format numbers right-justified using Console.WriteLine(), i.e I need to line up numbers in vertical columns and the MSDN documentation is pretty poor Here is the...
5
by: Publicjoe | last post by:
I am working on a little app which uses colour in the console window. I have created a class to extend the console functionality but the ClearScreen method does not work correctly. I am enclosing a...
5
by: portroe | last post by:
Hi I am using console.Writeline in my simple program. I do not however see anything happening in the output window when I debug, there are also no error messages, Has anybody a tip on what...
5
by: AdamM | last post by:
Hi all, Throughout my code, I have lines like this: Console.WriteLine("This is a sample with three variables: " + a + " and " + b + " and " + c); Are there any VS2005 IDE plugins or utilities...
2
by: djc | last post by:
out of all the overloads that pop up via intellisense for console.writeline() the following one confuses me: Console.WriteLine (string format, params object arg) 1) whats the deal with...
0
by: Zorquel | last post by:
I have an application that I want to accept command line arguments and if there are no command line arguments then go ahead and display the form and run it normally. However, if I use the command...
1
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...
3
by: Alex | last post by:
Hello, I'm wroting a console utility in VB 2005, and I need the ability to pass parameters to the application when the program runs. For example, if my program is called testing.exe, I need to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.