What is CLK_PER_SEC?

While reading some pages in the Ce 2e programming language, I found this.

clock_t clock(void)

: clock

Returns the CPU time used by the program since the start of execution, or -1 if it is not available. clock()/CLK_PER_SEC

is the time in seconds.

What is it CLK_PER_SEC

? This doesn't sound like a typo.

+3


source to share


4 answers


The manpage for clock(3)

is mentioned CLOCKS_PER_SEC

. glibc follows the same convention. It seems that the text you are citing is from the K&R 2nd edition, which is quite out of date. It is possible that the standard library was using CLK_PER_SEC

then, but this is certainly not the case now.



+3


source


It was probably a mistake in the 2nd book of K & R. The most recent reprints have CLOCKS_PER_SEC

, which is defined in the ANSI / ISO C standard (C89 / C99 / C11).

From errata :



Changes in Appendix B:

  • p 255: Change CLK_TCK

    to CLOCKS_PER_SEC

    .

Don't ask me what it is CLK_TCK

.

+3


source


Standard macro for clock ticks per second CLOCKS_PER_SEC

. See http://www.cplusplus.com/reference/ctime/CLOCKS_PER_SEC/ .

Some platforms define it CLK_PER_SEC

as an alias CLOCKS_PER_SEC

.

+1


source


This is the number of hours per second. U can find more information here: http://www.gnu.org/software/libc/manual/html_node/CPU-Time.html

0


source







All Articles