X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
From: "Robert D. Holtz - Lists" <robert.d.holtz@gmail.com>
To: <cygwin@cygwin.com>, "'Marcell Missura'" <missura@cs.uni-bonn.de>
References: <38624.131.220.7.1.1193151578.squirrel@webmail.iai.uni-bonn.de> <Pine.CYG.4.58.0710231015060.3388@PC1163-8460-XP.flightsafety.com>
Subject: RE: milliseconds on Windows
Date: Tue, 23 Oct 2007 10:36:52 -0600
Message-ID: <000201c81593$045ae260$02fea8c0@DDZG9K91>
MIME-Version: 1.0
Content-Type: text/plain; 	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Office Outlook 11
In-Reply-To: <Pine.CYG.4.58.0710231015060.3388@PC1163-8460-XP.flightsafety.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com


> Hello Brian,

http://cygwin.com/acronyms/#PPIOSPE

I've redirected this message and set the Reply-To appropriately.

> I'm a student at Bonn university and I'm researching robotics. I'm trying
> to write a robot controller for Windows XP (wasn't my choice!) and
> measuring elapsed time down to milliseconds precision is crucial. Do you
> happen to remember this discussion on the cygwin mailing list?
>
> On Mon, 12 Feb 2007, Carlo Florendo wrote:
>
> <snip>
>
> Re: strange bug in gettimeofday function
>
> > Windows could be accurate up to 15 ms or perhaps a little bit more.
> > However, it is very difficult to achieve less than 15 ms or microsecond
> > accuracy with windows due to the limitation on the OS itself.  Our
> > extensive tests on windows clocks and timers reveal that windows cannot
> > be accurate to the microsecond level or below 15 ms.
> >
> > In any case, in my experience, windows cannot be accurate with a
> > precision of up to 15 milliseconds.
>
> I'm sorry, could you repeat that value one more time, just in case someone
> missed it ;-).
>
> Anyway, I don't think it is relevant to the original thread's question,
> but I can assure you that Windows can be used for accurate timings in down
> to 1 or 2 ms (depending on the OS version).
>
> </snip>
>
> I'm experiencing pretty much the same thing as this guy. I'm using
> gettimeofday() to construct a timestamp and ran a test just like this:
>

Maybe try the solution I gave "this guy" (Carlo Florendo) on the cygwin
list?

> double timestamp;
> struct timeval tv;
>
> while(1)
> {
>  gettimeofday(&tv, NULL);
>  timestamp = tv.tv_sec + (double)tv.tv_usec/1000000;
>  printf("%f\n", timestamp);
> }
>
> Output:
>
> 1193149915.220881
> ... many times ...
> 1193149915.220881
> 1193149915.230881
> ... many times ...
> 1193149915.240881
>
> and so on. The timestamp changes every 10 ms.
>
> So if you know how to measure 1ms (less would be even better) on Win XP,
> can you please tell me how to do that?

If you're feeling frisky it's also possible to write a low level routine
that hooks the hardware clock and uses it for retrieving the time.

This clock does go down to microsecond granularity.



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

