Project Lambda: Java Language Specification draft
Jeroen Borgers
jborgers at xebia.com
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.
Regards,
Jeroen Borgers.
-----Original Message-----
From: coin-dev-bounces at openjdk.java.net [mailto:coin-dev-bounces at openjdk.java.net] On Behalf Of Rémi Forax
Sent: vrijdag 29 januari 2010 14:19
To: Zdenek Tronicek
Cc: coin-dev at openjdk.java.net
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:
http://blogs.sun.com/dholmes/entry/inside_the_hotspot_vm_clocks
Rémi
More information about the coin-dev
mailing list