JDK 10 RFR of 8182710: File.listRoots() always returns the root of CD drive
Brian Burkhalter
brian.burkhalter at oracle.com
Thu Jun 29 18:40:40 UTC 2017
Might as well go whole hog here so for grins I wrote a trivial JMH [1] micro-benchmark which gave these results:
Forks: 2
Warmup: 5 iterations, 2 s each
Measurement: 10 iterations, 3 s each
Version Mode Cnt Score Error Units
JDK 9 avgt 20 0.407 +/- 0.004 us/op
ArrayList avgt 20 505.389 +/- 2.965 us/op
IntStream avgt 20 522.015 +/- 3.040 us/op
BitSet avgt 20 507.290 +/- 1.812 us/op
These were obtained in a Windows 7 VirtualBox VM running on a macOS laptop and should be taken with a grain of salt in general, but they suggest that the ArrayList and BitSet versions are statistically equivalent and the IntStream version only slightly slower. However given that they are all three orders of magnitude slower than the version which does not check existence it hardly matters. Also it does not say a thing about the memory footprint or number of objects created, etc.
Brian
[1] http://openjdk.java.net/projects/code-tools/jmh/
On Jun 29, 2017, at 8:11 AM, Tagir Valeev <amaembo at gmail.com> wrote:
> Note that BitSet version removes single capturing lambda and additional stream step (every step creates at least two objects), so the tradeoff is not so obvious. Also it's probably possible that single-element array could be scalarized by JIT.
>
> With best regards,
> Tagir Valeev.
>
> On Thu, Jun 29, 2017 at 5:25 PM, Brian Burkhalter<brian.burkhalter at oracle.com> wrote:
>
> On Jun 29, 2017, at 7:21 AM, Roger Riggs <Roger.Riggs at Oracle.com> wrote:
>
> > Just interesting how much attention this snippet of code received. :)
>
> Agreed.
More information about the core-libs-dev
mailing list