Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: byte stream vs char stream buffer Date: Sun, 11 May 2014 09:05:16 +0000 (UTC) Organization: A noiseless patient Spider Lines: 37 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sun, 11 May 2014 09:05:16 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="13553"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Ynvvr9lq9rfYrUGsfS2hZjw3Shhf94dc=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:w0t5S05gbyS9mG84UxI85qj4PBs= Xref: csiph.com comp.lang.java.programmer:28433 On Sat, 10 May 2014 17:21:19 -0700, Roedy Green wrote: > On Sat, 10 May 2014 23:24:57 +0200, Robert Klemme > wrote, quoted or indirectly quoted someone > who said : > >>I don't think duplicate buffering will make things better. > > It does. And allocating your space exactly 50:50 makes a noticeable > difference. > > the plain Buffered reader was done like this: > > final BufferedReader ibr = new BufferedReader( new FileReader( > sampleDataFile ), buffsize / 2 ); > You said earlier that you were partitioning a fixed amount of buffer space between the BufferedInputStream and the BufferedReader, but that's not what your code shows. Instead the BufferedInputStream is getting part of a 'buffer space allocation', which is set to 32K. This part varies from 10% to 90% of the 32K while the BufferedReader always gets 16K. This means that the total buffer space used by the combination of BufferedInputStream and BufferedReader varies from 19.2 KB to 60.8 KB as the 'ratio' varies from 0.1 to 0.9. In other words, you're not measuring what you thought you're measuring because the total buffer space used by each test varies by a factor of three during the tests and will almost certainly affect your results. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |