At 13:23 05.06.2002 +0200, Georg Lundesgaard wrote: >Hi! > >I have followed this thread, and one thing strikes me: Are you buffering >in all three cases, >and the only thing different is the flushing? Looking at code in >FileAppender and >WriterAppender, I see that you wrap an winside a >BufferedWriter when >bufferedIO equals true, but when looking at Sun's javadoc (this JDK >1.2.2) I found the >following in OutputStreamWriter:
Yes, WriterAppender uses OutputStreamWriter which is wrapped by a BufferedWriter when BufferedIO option is set to true. >"Each invocation of a write() method causes the encoding converter to be >invoked on the given >character(s). The resulting bytes are accumulated in a buffer before >being written to the >underlying output stream. The size of this buffer may be specified, but >by default it is >large enough for most purposes. Note that the characters passed to the >write() methods are not >buffered. For top efficiency, consider wrapping an OutputStreamWriter >within a BufferedWriter >so as to avoid frequent converter invocations." Yes, OutputStreamWriter does its own buffering. Thank you for quoting the javadocs for OutputStreamWriter. It explains why buffered IO is faster when CPU cycles are scarce. (I am referring to the difference in performance between IO.java and IOFabien.java). BufferedWriter avoids frequent char conversion but does not help to reduce disk I/O. Less character encoding conversions use less CPU cycles, hence the improvement when using buffered IO on a heavily loaded server. >Does not this show that there are already some kind of buffering, and >that is way the test >show so little improve between buffering/no buffering? I'm no expert, >but isn't the 10-fold >improvement when you compare writing a single character at a time versus >writing an array of >say 1024 characters? Please do correct me if I'm completly wrong about >this. I remember I >learned something about this a couple of years ago... :) According to Jack Shirazi author of "Java Performance Tuning" a 10 or even 20 fold improvement is observed when you read a *line* at a time versus buffered reading which is 20x faster. The loss of performance should be even worse if you read one character at a time. >-- >Georg -- Ceki SUICIDE BOMBING - A CRIME AGAINST HUMANITY Sign the petition: http://www.petitiononline.com/1234567b I am signatory number 22106. What is your number? -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>