time the code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eternalLearner
    New Member
    • May 2007
    • 35

    time the code

    hi ,
    i need to calculate the actual running time of my code .
    that is i don't want the time wen my application is swapped out of the memory to show up in the time of the program,which actually happens wen i use the following :
    Code:
    time_t initialtime;
    time_t finaltime;
    (void)time(&initialtime);
    
    //do something 
    
    (void)time(&finaltime);//end of the time
    
    int time_taken  = finaltime - initialtime;
    please let me know if there is any other way to time the program,so the constraint i have specified is taken care of.
    thanks in advance.
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    Originally posted by eternalLearner
    hi ,
    i need to calculate the actual running time of my code .
    that is i don't want the time wen my application is swapped out of the memory to show up in the time of the program,which actually happens wen i use the following :
    Code:
    time_t initialtime;
    time_t finaltime;
    (void)time(&initialtime);
    
    //do something 
    
    (void)time(&finaltime);//end of the time
    
    int time_taken  = finaltime - initialtime;
    please let me know if there is any other way to time the program,so the constraint i have specified is taken care of.
    thanks in advance.

    Try using time <your executable> from command promt if u are running this in Unix.
    I hope this will give the required info

    raghu

    Comment

    • varnie
      New Member
      • Jun 2008
      • 6

      #3
      you can use, for example, Boost Timer Library. more info here:
      http://www.boost.org/doc/libs/1_35_0/libs/timer/timer.htm

      Comment

      • eternalLearner
        New Member
        • May 2007
        • 35

        #4
        Originally posted by gpraghuram
        Try using time <your executable> from command promt if u are running this in Unix.
        I hope this will give the required info

        raghu
        thanks,i will try it.

        Comment

        • eternalLearner
          New Member
          • May 2007
          • 35

          #5
          Originally posted by varnie
          you can use, for example, Boost Timer Library. more info here:
          http://www.boost.org/doc/libs/1_35_0/libs/timer/timer.htm
          thanks for the info :)

          Comment

          Working...