Mail Archives: cygwin/1998/01/18/22:31:50
On Fri, 16 Jan 1998, Benjamin Riefenstahl wrote:
> Hi Armin,
>
>
> herzer AT rz-nov5 DOT rz DOT fh-weingarten DOT de wrote:
> > I have written a data acquisation program with DJGPP. Now I want to
....snip...
>
> Look at the Win32 multimedia timers. They are the only thing that
> actually comes near that precision. The standard Win32 functions like
> GetSystemTime() have the resolution but not the actual granularity.
The routine below will time to the clock tick level (at least on
a pentium pro). Note that you have to put in the clock frequency.
rdtsc returns the hardware clock ticks as an 8 byte integer.
dclock converts the clock ticks to double precision seconds.
To compile 'gcc tst.c -o tstc'
/* begin tst.c */
#include <stdio.h>
long long rdtsc(void)
{
asm( "rdtsc");
}
double dclock(void)
{
double dtime;
static double rfrequency=1.0/200e6;
long long tsc;
tsc = rdtsc( );
dtime = tsc * rfrequency;
return( dtime );
}
int main()
{
double mytim;
double t1,t2;
t1=dclock();
while(dclock()-t1<10.0){;}
t2=dclock();
printf("did we go 10 secs? time=%f\n",t2-t1);
return 0;
}
/* end tst.c */
Pat
>
>
> so long, benny
> ======================================
> Benjamin Riefenstahl (benny AT crocodial DOT de)
> Crocodial Communications EntwicklungsGmbH
> Ophagen 16a, D-20257 Hamburg, Germany
> -
> 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".
>
Patrick Fay, Ph.D., Intel Corp. email: pfay AT co DOT intel DOT com
Los Alamos National Lab wk: (505) 665-9141
CTI M.S. B296 fax: (505) 667-5921
Los Alamos NM 87545 ASCI-RED http://www.acl.lanl.gov/~pfay/teraflop
-
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".
- Raw text -