what do the values of "clocks ticks" and "CLOCK_PER_SEC" represent?

C

chandanlinster

what do the values of "clocks_ticks = sysconf(_SC_CLK_TCK);" and
"CLOCK_PER_SEC" represent?
 
J

Jens Thoms Toerring

chandanlinster said:
what do the values of "clocks_ticks = sysconf(_SC_CLK_TCK);" and
"CLOCK_PER_SEC" represent?

"CLOCKS_PER_SEC" (I guess you meant that) is the time the value
returned by the function clock() must be divided by to give a
time in seconds. What the non-standard-C (but POSIX) function
sysconf() returns for "_SC_CLK_TCK" (also not a standard-C but
POSIX defined value) is the time resolution the values returned
by the times() function are in (you may already have guessed
that this is also not a standard-C but POSIX function;-).They
typicaly are the not the same. And neither of them is meant to
be confused with the clock rate of the processor(s).

Regards, Jens
 
T

Tim Prince

Jens said:
"CLOCKS_PER_SEC" (I guess you meant that) is the time the value
returned by the function clock() must be divided by to give a
time in seconds. What the non-standard-C (but POSIX) function
sysconf() returns for "_SC_CLK_TCK" (also not a standard-C but
POSIX defined value) is the time resolution the values returned
by the times() function are in (you may already have guessed
that this is also not a standard-C but POSIX function;-).They
typicaly are the not the same. And neither of them is meant to
be confused with the clock rate of the processor(s).
I'm grateful for this explanation. In addition, it's often said that
POSIX dictates a fixed value of 1000000 for CLOCKS_PER_SEC, which seems
to me to be at odds with satisfactory C usage. This leads to what I
would call wasting 10000 increments in the typical case where clock()
has a physical resolution of 0.010 second. You find this out, for
example, by evaluating clock() in a loop and finding that it increments
by 10000 whenever it changes.
This unfortunate situation increases the incentive to use alternatives
to standard C clock().
 
J

Joe Estock

chandanlinster said:
Thanks a lot for the explaination!!!
What explanation? You really need to include context when you post. My
news server has expired the original article to which you are replying.

Does anyone still have the original article along with the reply and if
so could you post it please?
 
C

Coos Haak

Op Tue, 13 Feb 2007 07:29:18 -0600 schreef Joe Estock:
What explanation? You really need to include context when you post. My
news server has expired the original article to which you are replying.

Does anyone still have the original article along with the reply and if
so could you post it please?

I agree fully, but why wait more than twelve days to reach to this
conclusion ? ;-)
 
J

Joe Estock

Coos said:
Op Tue, 13 Feb 2007 07:29:18 -0600 schreef Joe Estock:


I agree fully, but why wait more than twelve days to reach to this
conclusion ? ;-)

It's not intentional; I seem to have less and less of this "free time" I
hear so many people talking about these days and it takes me a while to
catch up. It was by chance I even saw this article in the first place.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top