I was trying to comprehend CPU time and processor time. And they said "On a 32bit system with CLOCKS_PER_SEC set to one million this function will return the same value approximately every 72 minutes." Why is this so?
Asked
Active
Viewed 446 times
0
-
2Maybe this can help you http://stackoverflow.com/questions/10455905/clocks-per-sec-not-actually-clocks-per-sec – ganchito55 Feb 11 '16 at 09:48
-
CLOCKS_PER_SECOND need not always be set to 1 million. The statement you quote doesn't claim that it does. – davmac Feb 11 '16 at 11:29
-
Does CLOCKS_PER_SECOND even exist? CLOCKS_PER_SEC is in the C standard though. – Jetski S-type May 15 '20 at 01:22
1 Answers
2
Say you have 72 minutes, so 72*60 seconds which equals to 4320, then as at each second you have 1000000 ticks you finally have 4320000000 ticks each 72 minutes. 4320000000 is approximatively the maximum value an unsigned 32 bit int could store before overflowing.
Now the title of your question as nothing to do with the content of your message. What is the question?

Jean-Baptiste Yunès
- 34,548
- 4
- 48
- 69
-
Thanks. That is really helpful. But at each second, we have 1000000 ticks? Why? That exactly is the title of my question. Should n t this depend on the specific processor? – hAcKnRoCk Feb 22 '16 at 14:07
-
2This is not «processor clock», this is a free-running counter. When the value of `clock()` is incremented by one, you know that about 1/1000000sec. elapsed, that's all. The kernel is responsible to behave such and to give you the best approximation for processor time used by your process. The value guarantee you that you will measure approximated process's on-processor time with µ-sec accuracy. – Jean-Baptiste Yunès Feb 22 '16 at 15:13