Subject: Re: Clock() bug on B19
From: [email-masked] (Hilton Fernandes)

29 Apr 1998 06:28:54 -0700
Sender: [email-masked]
Message-ID: <[email-masked]>
References: <[email-masked]>
Reply-To: Hilton Fernandes <[email-masked]>
To: Tein Horng Yuan wrote <[email-masked]>, [email-masked]
Cc: Hilton Fernandes <[email-masked]>
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 [email-masked]
> 
> 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 <windows.h> /* GetTickCount() */

#include <stdio.h>
#include <math.h>

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
"[email-masked]" with one line of text: "help".