Project Lambda: Java Language Specification draft

Jeroen Borgers jborgers at
Fri Jan 29 07:02:51 PST 2010

Hi Remi,

Personally I'm also very cautious with using System.nanoTime(). Like David Holmes points out:

"Be aware though, this call [nanoTime()] can also take microseconds to execute on some platforms."

While currentTimeMillis() only takes a few clock cycles, nanoTime() takes microseconds on Windows. So, nanoTime can cause considerable overhead if you do a lot of measurements inside applications. It can also distort measurements in micro benchmarks.

Jeroen Borgers.

-----Original Message-----
From: coin-dev-bounces at [mailto:coin-dev-bounces at] On Behalf Of Rémi Forax
Sent: vrijdag 29 januari 2010 14:19
To: Zdenek Tronicek
Cc: coin-dev at
Subject: Re: Project Lambda: Java Language Specification draft

Le 29/01/2010 13:46, Zdenek Tronicek a écrit :
> Hi Remi,
> System.nanoTime() is not very suitable for performance tests because
> neither Unix nor Windows have resolution of 1ns. The resolution is
> typically 100-1000 times lower.
> So, I changed System.nanoTime() to System.currentTimeMillis(), increased
> the size of the list to 1000000 (million), and looping through get() is
> faster than looping through Iterator. Difference is approx. 7%.
> (On Windows XP, Intel).
> Z.

This is not what David Holmes says:


More information about the coin-dev mailing list