0

To whoever is using the following code for timing code execution in C
Originally Posted by [B]vijayan121 [/B]

#include<time.h>
blah blah
 main()   
{      
      clock_t start, end;
      double cpu_time_used;
      start = clock();
       /* whatever */
       end = clock();
       cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;

}

if you are wondering why the time displayed is compiler specific instead of being processor specific the solution is here:
Applications should use sysconf(_SC_CLK_TCK) to determine the number of clock ticks per second as it may vary from system to system.
http://www.opengroup.org/onlinepubs/000095399/functions/times.html
http://www.opengroup.org/onlinepubs/000095399/functions/sysconf.html
Courtesy great google and opengroup.org

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Ancient Dragon
0

Your post has two flaws:
1) it assume the user is running *nix operating system. That may, or may not be correct.

2) Your post is irrelevent because it has nothing at all to do with using the clock() function.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.