Link Details

This blog explains the performance issue with Java IO Buffered Streams

Posted by tarun-dzone  |   May 23 2011 / 01:39

Add your comment

Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.


User 211643 avatar

zynasis replied ago:

14 down votes without reason???

Reply 0 votes
User 273999 avatar

matthewdfleming replied ago:

It was probably voted down due to an inaccurate test (see comments on blog).

Reply 0 votes
User 468111 avatar

tarun-dzone replied ago:

Its not an inaccurate test, buffered streams use the buffer internally. Hence I did not use the buffer in first program. If you take the source code from the JAVA IO package for Buffered Streams and just remove the synchronized keywords from the code. You will see the difference.

I may be wrong but someone needs to prove with appropriate test code.

Reply 0 votes
User 416683 avatar

Kapil Jain replied ago:

Well I found an article whose benchmarks shows buffersteam have better performance
Btw I think default buffer size is 512 bytes

Reply 0 votes
User 468111 avatar

tarun-dzone replied ago:

In the article you have mentioned there are 3 key points mentioned at the end, I have tried to prove the same in my article.

Reading and writing data using default behavior of some streams that is byte by byte read/write causes slow performance.
Buffered input streams and buffered output streams increase performance.
Custom buffering increases performance significantly.

Reply 0 votes
User 416683 avatar

Kapil Jain replied ago:

yes, Tarun thats the point !!! One should look into the details first without blindly following the concept. Buffer streams are better than the default behavior but not when bytes are read directly. There is one more point regarding the custom buffering that it loads all the bytes in the memory so that might put load on the RAM.

Reply 1 votes

Recommended Links

Written by: Ryan Knight
Featured Refcardz: Top Refcardz:
  1. Apache Hadoop
  2. Play
  3. Akka
  4. Debugging JavaScript
  5. Design Patterns
  1. Apache Hadoop
  2. REST
  3. Java
  4. Git
  5. Java Performance
Connect with DZone