X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org From: "Robert D. Holtz - Lists" To: , "'Marcell Missura'" References: <38624 DOT 131 DOT 220 DOT 7 DOT 1 DOT 1193151578 DOT squirrel AT webmail DOT iai DOT uni-bonn DOT de> 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: X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT 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: > > > > 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). > > > > 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/