Speed comparison

This is a discussion on Speed comparison within the C# Programming forums, part of the General Programming Boards category; What kind of performance difference will i see between code being run through the debugger as opposed to creating a ...

  1. #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

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Nope.

  3. #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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. I am very new . . . :(
    By Eternalglory47 in forum C++ Programming
    Replies: 6
    Last Post: 09-05-2008, 11:29 AM
  3. Speed comparison between vector and 2*2 array
    By cunnus88 in forum C++ Programming
    Replies: 5
    Last Post: 11-25-2007, 01:05 AM
  4. Flight Simulator Wind Speed!!
    By Dilmerv in forum C++ Programming
    Replies: 6
    Last Post: 03-19-2006, 11:40 PM
  5. C/C++ vs assembly: speed comparison
    By Just in forum C++ Programming
    Replies: 11
    Last Post: 11-25-2002, 02:33 PM

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