|
From: Eric <eri...@cl...> - 2004-12-30 02:50:24
|
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
On Thu, 30 Dec 2004, Eric wrote:
> Hi Malcolm
> I just tried it again and got 990 then 1040
>
> I wonder why? I have a Pentium 4, 2GHz, "GenuineIntel" (according to the control panel.) windows 98se
>
> >From Eric
>
>
>
> We are all here on earth to help others;
> what on earth the others are here for I don't know!
>
>
>
> ----- Original Message -----
> From: "Malcolm Nealon"
> To: <dev...@li...>
> Sent: Thursday, December 30, 2004 12:03 AM
> Subject: Re: [Dev-C++] time - try this,
>
>
> Hello Eric,
>
> On 29 December 2004, 11:11:18, you wrote:
>
> > #include<time.h>
> > #include<stdio.h>
>
> > int main(void)
> > {
> > clock_t ticks1, ticks2;
>
> > ticks1=clock();
> > ticks2=ticks1;
> > while((ticks2/CLOCKS_PER_SEC-ticks1/CLOCKS_PER_SEC)<1)
> > ticks2=clock();
>
> > printf("Took %ld ticks to wait one second.\n",ticks2-ticks1);
> > printf("This value should be the same as CLOCKS_PER_SEC which is %ld.\n",CLOCKS_PER_SEC);
> > return 0;
> > }
>
> This produces 1000
>
>
> while(((ticks2-ticks1)/CLOCKS_PER_SEC)<1)
> ticks2=clock();
>
>
> --
> Best regards,
> Malcolm
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://productguide.itmanagersjournal.com/
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://productguide.itmanagersjournal.com/
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|