From: hgfernan AT usp DOT br (Hilton Fernandes) Subject: Re: Clock() bug on B19 29 Apr 1998 06:28:54 -0700 Sender: root AT cygnus DOT com Message-ID: <9804281735.AA69488.cygnus.gnu-win32@spider.uspnet.usp.br> References: <35405FAB DOT D08B9A3F AT dont DOT send DOT me DOT junk DOT mail> Reply-To: Hilton Fernandes To: Tein Horng Yuan wrote , gnu-win32 AT cygnus DOT com Cc: Hilton Fernandes MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII On 24 Apr 98 at 17:47, Tein Horng Yuan wrote: > Hi, > > I am running gnu-win32 B19-1 on a PII-233 system. Because I need to > measure > the CPU time, I find out 'clock' is not function correct. A test > program is attached. > Please send me email to tyuan AT beta DOT wsl DOT sinica DOT edu DOT tw > > By the way, will you have Pentium II optimization version of gcc? > Thanks. > > -- Tein Hello, please use the GetTickCount() function of the Win32 API. It returns the number of milliseconds that have elapsed since Windows was started. I changed your program a little to include this modification as well as eliminate gcc -Wall warnings. Hope it is helpful, --Hilton --------------------------------------------------------------------- #include /* GetTickCount() */ #include #include typedef double REAL; REAL second(void) { return ( ((REAL)GetTickCount ()) / ((REAL)1000.0) ); } int main (void){ /* explicit main return type */ double a,b,c; // long i,j,k,l,m,n,o,p; /* vars not used should be eliminated */ long i, k,l; c= 0; b= second(); for(i=0; i<1024 * 1024 * 1024; i ++) { for(k=0; k<1024 ; k ++) for(l=0; l<1024 ; l ++) a = sin(l) + cos(k); c=b; b=second(); // c= c - b; c = b - c; // b is later than c printf("%ld, %f, %f\n", i, b, c); /* i is long, use a long format */ } return (0); /* to make gcc -Wall happy */ } - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".