delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/03/22/01:00:30

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-ID: <5F4D0B436B7FD311B00C0008C724ADA6018C0A2C@ntmsg0009.corpmail.telstra.com.au>
From: "Wong, Homer" <Homer DOT Wong AT team DOT telstra DOT com>
To: cygwin AT sourceware DOT cygnus DOT com
Cc: "Wong, Homer" <Homer DOT Wong AT team DOT telstra DOT com>
Subject: Can Cygwin's gettimeofday() count to 30us resolution instead of 1
0ms?
Date: Wed, 22 Mar 2000 16:57:43 +1100
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)

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 AT telstra DOT com DOT au

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019