public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Can Cygwin's gettimeofday() count to 30us resolution instead of 10ms?
@ 2000-03-21 21:59 Wong, Homer
  0 siblings, 0 replies; only message in thread
From: Wong, Homer @ 2000-03-21 21:59 UTC (permalink / raw)
  To: cygwin; +Cc: Wong, Homer

Hi

Can Cygwin's gettimeofday() measure down to Linux's 30us (microsecond) timer
resolution instead of Windows' 10 ms (millisecond) timer resolution? I used
the following program to test gettimeofday():

#include <time.h>
#include <stdio.h>
#include <sys/time.h>

int main()
{
        struct timeval tv;

        int i;
        for (i=0; i<1000;i++)
        {
                gettimeofday(&tv, (struct timezone *) 0);
                printf("%lf \n", tv.tv_sec * 1000000.0 + tv.tv_usec );
        }
}

When I compiled it using Cygwin B20.1 on a Pentium II ??? Windows NT box,
the (annotated) output was:

217722273000.000000 (repeated ??? times)
217722283000.000000 (repeated 287 times)
217722293000.000000 (repeated 287 times)
217722303000.000000 (repeated 287 times)
217722313000.000000 (repeated ??? times)

Basically, it was only measuring at 273ms, 283ms, 293ms i.e. about every
10ms.

When I compiled it using gcc-2.7.2.1-2 on a Pentium II ??? Red Hat Linux 4.2
box, I got 1000 uniq time values e.g.:
953703420374555.000000 
953703420374954.000000 
953703420374986.000000 
953703420375010.000000 
953703420375032.000000 
953703420375055.000000 
<etc>

This was much better, measuring at 374.555ms, 374.954ms, 374.986ms,
375.010ms i.e. about every 30us.


The Linux code for gettimeofday() is in
/usr/src/linux/arch/i386/kernel/time.c or
http://src.openresources.com/linux-2.2.1/S/arch%20i386%20kernel%20time.c.htm
l#250 or http://src.openresources.com/linux-2.2.1/D/do_gettimeofday.html .


Homer Wong,
Telstra, Australia
hwong@telstra.com.au

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-03-21 21:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-21 21:59 Can Cygwin's gettimeofday() count to 30us resolution instead of 10ms? Wong, Homer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).