Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: byte stream vs char stream buffer Date: Sat, 10 May 2014 23:24:57 +0200 Lines: 44 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 Ggkfww7E5g6o75jLK/ZysQc5i4qTpNVb9RFwpbCeS6kV1jC/s= Cancel-Lock: sha1:op5vs3H0b+vnsc+/0PMWrED1YUE= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:28426 On 10.05.2014 22:18, Roedy Green wrote: > On Fri, 09 May 2014 09:34:09 -0700, Roedy Green > wrote, quoted or indirectly quoted > someone who said : > >> On Thu, 8 May 2014 13:30:15 +0000 (UTC), Andreas Leitgeb >> wrote, quoted or indirectly quoted >> someone who said : >> >>> I'm wondering, if your lego stack is higher than necessary. Are you >>> placing BufferedWriter over BufferedOutputStream? I think you can >>> put the BufferedOutputStream back into the lego bag in that case. ;) >> >> I think some experiments are in order. > > There are the results: > Using a file of random characters of 400 MB and buffers of 32K bytes > > HunkIO 1.20 seconds <-- does an all at once read. > using BufferedReader backed with BufferedInputStream ratio 0.50 > buffsize 32768 bytes 1.65 seconds > plain BufferedReader buffsize 32768 bytes 1.76 seconds I find this a fairly unspecific description of the test you did. We do not know what your test did to ensure file system caching or GC effects did not influence the measurement etc. > The bottom line is either use HunkIO when you have the RAM or give 50% > of your buffer space to the inputstream and 50% to the Reader > in other works 100K of buffer space would have a 50K inputstream > buffer and the reader would have a 25K buffer because it is measured > in chars. I tried ratios from .1 to .9. 50% was best. If I'm not mistaken you did not test cases where there is just a BufferedReader OR a BufferedInputStream - that was what Andreas was hinting at if I'm not mistaken. I don't think duplicate buffering will make things better. I had expected at least three tests (double buffering, byte buffering, char buffering) plus the code. Cheers robert