[concurrency-interest] java.lang.System.nanoTime and QueryPerformanceCounter-"Bug"

Michael Mayr Michael.Mayr@web.de
Tue, 23 Dec 2003 23:42:09 +0100


The last few days I have been investigating "exact" time measuring in Java. During my investigations I found your project. nanoTime() will surely be a very useful addition to the Java platform. During my investigations I also found out that on Windows platforms some chipsets cause leaps forward in time (up to a few seconds) when using the QueryPerformanceCounter-Call (which is -to my knowledge- the only way to measure in nanoseconds on Windows). This behavior is documented under:


I took a look at your viewcvs-webinterface but couldn't find any native code. So I couldn't check if you do take this fact into account. IMHO leaps should be detected and if they are detected nanoTime() should return a nonvalid time (e.g. a negative time). I think it is not useful having a wrong time with a leap for profiling or anything like this.

I hope I could help.  (Don't say you haven't been warned ;-) )

Nachrichten, Musik und Spiele schnell und einfach per Quickstart im 
WEB.DE Screensaver - Gratis downloaden: http://screensaver.web.de/?mc=021110