Fw: Patch for File Scanning
Mike Skells
mike.skells at talk21.com
Tue Oct 11 17:09:49 PDT 2011
Hi Alan, Remi,
Resending as it didnt get to the list
On my test case (scanning the 946 directories in rt..jar) I compared the CPU cost of the holder pattern vs. creation of a new filter
using System.nanotime() to measure the time
holder 1.5ms
new filter = 2.3 ms
All tests from a fresh VM, running window 64bit
So there is a little less than 1ms related to this part of the patch, but there does appear to me to be little downside (with the holder pattern), but then I am biased
regards
Mike
Hi Alan,
>>It certainly was not the bigest CPU saving in the patch, but it did contribute.
>>I will produce some stats to see what it uses for me.
>>
>>
>>This is not really the introduction of a new class, as there is an anonymous class anyway with is being named, so the holder is effectively for free in this case
>>
>>
>>Regards
>>Mike
>>
>>Alan Bateman wrote
>>
>>
>>>________________________________
>>>From: Alan Bateman <Alan.Bateman at oracle.com>
>>>To: Rémi Forax <forax at univ-mlv.fr>
>>>Cc: nio-dev at openjdk.java.net
>>>Sent: Monday, 10 October 2011, 1:16
>>>Subject: Re: Fw: Patch for File Scanning
>>>
>>>
>>>Rémi Forax wrote:
>>>
>>>>You can solve this by using the lazy loading of the class.
>>>>
>>>>static class AcceptAllFilter implements Filter<Object> {
>>>> static final Filter<Object> ACCEPT_ALL = new
AcceptAllFilter();
>>>>
>>>> @Override
>>>> public boolean accept(Object entry) {
>>>> return true;
>>>> }
>>>>}
>>>>
>>>>...
>>>>return provider(dir).newDirectoryStream(dir,
AcceptAllFilter.ACCEPT_ALL);
>>>>
>>>>
Sure, but it's just not clear that we need yet another class for this
(since we started using the holder idiom then we've added quite a few
classes and for this specific case, I'm not convinced that creating the
filter object is really an issue).
>>>
>>>-Alan.
>>>
>>>
>>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20111012/3d6a799a/attachment.html
More information about the nio-dev
mailing list