Thread: Speed

  1. #1
    Registered User
    Join Date
    May 2004


    Hey everyone. You know how simple operations take different speeds? For example, addition takes less time than division. Reading takes less time than assigning. (I think) (You get the point)

    Is there some sort of table that can tell me the speeds? Or a way I can determine it? I'm trying to make a processor-intensive area faster, and I came on this problem:

    Is it faster like this...
    int Operation( int A, int B )
       int C = A + B;
       return C * C;
    int Operation( int A, int B )
       return ( A + B ) * ( A + B );
    It's a question of which is faster, two additions or making another integer.

    So is there some sort of table somewhere? Or a way I can find out the speeds of these operations?

  2. #2
    Registered User
    Join Date
    Jan 2005
    It doesn't matter which is faster. Choose the one that is clearer (as long as they are close in efficiency).

    If you really want to know, you can do performance tests to see.

    I don't know of any table or resource that has that information right at hand, though. You kind of have to pick up on things as you learn.

  3. #3
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Just run each operation a 100 million times in a for loop and time it yourself. I seriously doubt you'll find even the slightest bit of difference in time.

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Ontario, Canada
    One way to check, if you're using gcc, is to use the -S flag and compare the resulting assembly that is generated.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I am very new . . . :(
    By Eternalglory47 in forum C++ Programming
    Replies: 6
    Last Post: 09-05-2008, 11:29 AM
  2. Flight Simulator Wind Speed!!
    By Dilmerv in forum C++ Programming
    Replies: 6
    Last Post: 03-20-2006, 12:40 AM
  3. Replies: 6
    Last Post: 01-08-2006, 02:49 PM
  4. increased net speed
    By PING in forum A Brief History of
    Replies: 20
    Last Post: 03-29-2005, 07:05 AM
  5. Questions on Speed of Execution
    By wavering in forum C Programming
    Replies: 22
    Last Post: 01-20-2002, 02:04 PM