Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!storethat.news.telefonica.de!telefonica.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: The first 10 files Date: Fri, 15 Mar 2013 11:38:02 +0100 Lines: 37 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 1W1r3n36q5bxpqb9Yw437AHqktd/oErtnMLN5TeKe2wNrF9SA= Cancel-Lock: sha1:coe1BwwUKsvkXkQ226vNNG8LWc8= User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 In-Reply-To: X-Antivirus: avast! (VPS 130315-0, 15.03.2013), Outbound message X-Antivirus-Status: Clean Xref: csiph.com comp.lang.java.programmer:22958 On 14.03.2013 11:07, Wojtek wrote: > So NIO is about 4-5 times faster than IO. The first NIO run looks like > an anomoly, might be some JRE loading happening. > > All the runs produce different timings, might be a Windows caching > effect. However the NIO is consistently much faster overall. I am not convinced that this conclusion is warranted. There are a few factors which I believe make your conclusion questionable: - You included class loading time in your measurement. For example, assuming that all io functionality is implemented on top of nio it would be logical to expect more classes to be loaded. There are a number of use cases where it matters - but there are also use cases where it doesn't matter (long running servers). - Generally we are dealing with quite low timings (around 100ms) and relatively high variations. Also the test was made on Windows and the System.currentTimeMillis() is known to be imprecise on that platform (in the order of tens of milliseconds). - Your io approach does not use FileFilter which some have suggested to be a way to avoid constructing a large result array. - The test is an artificial situation. With all factors like JVM involved it may be that in a realistic application things look different to an extent that the differences you measured here do not matter any more. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/