Issue
I was wondering what is the difference between the return value of the aforementioned constants.
sysconf(_SC_CLK_TCK)
returns 100
CLOCKS_PER_SEC
returns 1,000,000
So, suppose that I have this:
...
start = clock();
// Process starts here
/* does something */
// Process ends here
end = clock();
double time = ((double) end-start)/CLOCK_PER_SEC; // this would return in seconds
...
How do I calculate the amount of ticks used by the process, instead of the time? Do I use time used against sysconf(_SC_CLK_TCK)
or CLOCK_PER_SEC
?
I am trying to understand the usage of those.
Solution
As per the documentation, clock()
returns time in resolution of CLOCKS_PER_SEC
.
Other time functions return values with resolution in ticks. sysconf(_SC_CLK_TCK)
provides the number of ticks per second. One such time function is times()
.
Answered By - jxh Answer Checked By - David Goodson (WPSolving Volunteer)