X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Date: Sun, 7 Jul 2013 16:36:49 -0400 Message-Id: <201307072036.r67KanNk031567@envy.delorie.com> From: DJ Delorie To: djgpp AT delorie DOT com In-reply-to: (lordwilliams1972 AT gmail DOT com) Subject: Re: CLOCKS_PER_SEC of time.h doesn't work to prove it is a value for one second References: Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > ticks1=clock(); > ticks2=ticks1; > while((ticks2/CLOCKS_PER_SEC-ticks1/CLOCKS_PER_SEC)<1) > ticks2=clock(); What you should do is write a djgpp program that prints clock()'s value to the screen, and time it from 0 to 9100 clock()s with a stopwatch. All your code is doing is incrementing ticks2 (by 5) until it's CLOCKS_PER_SEC more than ticks1, modulo whatever ticks1 started at. You could have done this and gotten similar results: > ticks1=0 > ticks2=ticks1; > while((ticks2/CLOCKS_PER_SEC-ticks1/CLOCKS_PER_SEC)<1) > ticks2 += 5; Note that, because of the "* 5", the value you get could be off by as much as 4 due to the fact that clock() will *always* return a multiple of 5. However, the increment from one clock() to the next clock() is not always the *same* multiple of 5. Try using "< 100" instead of "< 1" in your code and see what happens. That will give you an average value, not one test value.