C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-07-2008, 03:23 PM   #1
Registered User
 
Join Date: Oct 2008
Posts: 85
Speed comparison

What kind of performance difference will i see between code being run through the debugger as opposed to creating a standalone project for checking?

This is working on the premise that there are no watch points or break points active and i am just checking through the running state.

Should this be a concern on a small test project ?

i am continually improving my code as i go, as and when i establish better ways to achieve the same goal. but does this :-

Code:
int x;
int y;

x= 50;
y= 50;
for (x=0;x<10;x++)
{
for (y=0;y<10;y++)
{
//dosomething here
}
}
execute any faster than this :-

Code:
for(int x=0;x<10;x++)
{
for(int y=0;y<10;y++)
{
//do something here
}
}
apart from readability, is it any less efficient to declare things as you go ?

thanks
deviousdexter is offline   Reply With Quote
Old 11-07-2008, 04:08 PM   #2
Banned
 
master5001's Avatar
 
Join Date: Aug 2001
Location: Visalia, CA, USA
Posts: 3,699
Nope.
master5001 is offline   Reply With Quote
Old 11-10-2008, 04:42 PM   #3
Registered User
 
Join Date: Aug 2008
Posts: 188
don't worry about this stuff. the compiler will optimize it most of the time for you anyways. but assuming no optimizations, the 1st version is slower because x,y are declared to 0 (for C#, not C++), and then it's set to 50, and then it's set to 0 again. the 2nd version it gets set once.
bling is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to sort a simple linked list using swap-sort method JOCAAN C Programming 24 08-07-2009 11:48 AM
I am very new . . . :( Eternalglory47 C++ Programming 6 09-05-2008 11:29 AM
Speed comparison between vector and 2*2 array cunnus88 C++ Programming 5 11-25-2007 02:05 AM
Flight Simulator Wind Speed!! Dilmerv C++ Programming 6 03-20-2006 12:40 AM
C/C++ vs assembly: speed comparison Just C++ Programming 11 11-25-2002 03:33 PM


All times are GMT -6. The time now is 04:02 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22