|
From: Per W. <pw...@ia...> - 2004-12-30 05:23:17
|
Guess what. I normally _always_ test things before sending out answers. Why do you think I said that one machine stepped with 10ms granularity, and another with 15.625ms? Anyway, the program always endied after >= CLOCKS_PER_SEC ticks. /Per W On Thu, 30 Dec 2004, Eric wrote: > XXXXXXXXX > > Sorry > > > ----- Original Message ----- > From: "Eric" <eri...@cl...> > To: "Per Westermark" <pw...@ia...> > Cc: <dev...@li...> > Sent: Thursday, December 30, 2004 3:47 PM > Subject: Re: [Dev-C++] time - try this, > > > CAN YOUI JOKERS STOP LOOKING AT THE ##### CODE ANF JUSTR TRY THE %$%%%t% THING, i DON'T ASJFOPE MUCG > > > ----- Original Message ----- > From: "Per Westermark" <pw...@ia...> > To: "Eric" <eri...@cl...> > Cc: <dev...@li...> > Sent: Thursday, December 30, 2004 12:39 PM > Subject: Re: [Dev-C++] time - try this, > > > If you do > > ((ticks2 - ticks1) / CLOCKS_PER_SEC) < 1 > > (observe difference before division) there is no possibility that you can > get an answer less than 1000. If you do two divisions, you might get into > problems because of the round-off errors you introduce. > > While you have to divide the value from clock() with CLOCKS_PER_SEC to get > seconds, there is no guarantee that the value returned by clock() can > assume all possible values, i.e. if CLOCKS_PER_TICK is 1000, it is still > possible that the only values you can get are 32, 64, 96 etc if the actual > clock only counts in 32ms resolution. In real life, most of the time, > clock() steps with a non-integer number of ticks because the underlying hw > might tick on a frequency that is > > For Posix compliance, CLOCKS_PER_SEC should _always_ be 1000000 i.e. > microsecond resolution, even of the real computer clock can't tick once > every us. > > On one of my machines - WinXP, P4 HT - the possible steps are 15.625ms, > i.e. I get the values 15,31,62,78,... for a total of 64 values/second. > > On another machine using Linux, clock() steps exactly exactly every 10ms, > but since the resolution is in us, the possible values increases with > 10000 at a time. > > /Per W |