Thanks for the replies and the links gents. Still confused. I can understand 
that you can’t expect nanosecond resolution but the diff I noticed is 1-6 ms... 
on a 10 ms interval. Those are eternities in modern day CPUs.

I am planning to use the stopwatch with a second resolution so this test is 
kinda irrelevant but I am still surprised by the result. I might take a look at 
the implementation later to get a better understanding. 

Thanks again for the help.


Erwin

El jun. 6, 2019, a la(s) 22:41, Remko Popma <remko.po...@gmail.com> escribió:

> Timers and elapsed time in Java is an interesting topic. Can be a moving 
> target though...
> 
> Some recent articles:
> https://hazelcast.com/blog/locksupport-parknanos-under-the-hood-and-the-curious-case-of-parking/
> 
> https://hazelcast.com/blog/locksupport-parknanos-under-the-hood-and-the-curious-case-of-parking-part-ii-windows/
> 
> Remko.
> 
> (Shameless plug) Every java main() method deserves http://picocli.info
> 
>> On Jun 7, 2019, at 6:13, Gary Gregory <garydgreg...@gmail.com> wrote:
>> 
>> The OS' clock resolution is in play here, which depending on your OS will
>> give you varying results. Also, on Java 9, you get better clock resolution
>> for certain APIs. Kinda messy...
>> 
>> Gary
>> 
>> On Thu, Jun 6, 2019 at 4:28 PM Erwin Hogeweg <erwin.hoge...@me.com.invalid>
>> wrote:
>> 
>>> Hi,
>>> 
>>> I am tad confused about the StopWatch resolution. I have a very basic
>>> JUnit test that starts a stopwatch, wait for 10ms and then stops it, and
>>> checks the value. In about 40% of the cases it is less than the 10ms wait
>>> time.
>>> 
>>> Is that expected? What is my blind spot?
>>> 
>>> 
>>> Regards,
>>> 
>>> Erwin
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
>>> For additional commands, e-mail: user-h...@commons.apache.org
>>> 
>>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to