From: Roedy Green on 20 Feb 2010 16:20 On Sat, 20 Feb 2010 11:48:43 +0000, Tom Anderson <twic(a)urchin.earth.li> wrote, quoted or indirectly quoted someone who said : >Writer w = new BufferedWriter(new OutputStreamWriter(out)); >Writer w = new OutputStreamWriter(new BufferedOutputStream(out)); Turns out neither is best. The best in splitting your buffer space in half and using half for BufferedOutputStream and half for BufferedWriter. (the optimal split has yet to be determined.) The differences are substantial. // Speeds are in seconds averaged over 2 trials using 104,857,600 character files and 65,536 character buffers. // BufferedWriter 5.53 // BufferedOutputStream 25.64 W O R S T // DoubleBufferedWriter 3.67 B E S T // BufferedReader 5.16 // BufferedInputStream 17.18 W O R S T // DoubleBufferedReader 4.17 B E S T Code is posted at https://wush.net/websvn/mindprod/filedetails.php?repname=mindprod&path=%2Fcom%2Fmindprod%2Fexample%2FTestBuffered.java -- Roedy Green Canadian Mind Products http://mindprod.com When a newbie asks for help tracking a bug in a code snippet, the problem is usually is the code he did not post, hence the value of an SSCCE. see http://mindprod.com/jgloss/sscce.html
From: Roedy Green on 20 Feb 2010 16:28 On Sat, 20 Feb 2010 15:41:51 -0500, Lew <noone(a)lewscanon.com> wrote, quoted or indirectly quoted someone who said : >Tom Anderson wrote, quoted or indirectly quoted someone who said : >>> Writer w = new BufferedWriter(new OutputStreamWriter(out)); >>> Writer w = new OutputStreamWriter(new BufferedOutputStream(out)); > >Roedy Green wrote: >> It turns out it makes a huge difference. I will post code shortly. > >Please also show the environment and which one won. > >I wonder if things like RAM, CPU, disk subsystem performance and such >influence the outcome. Full description of my machine is at http://mindprod.com/contact/equipment.html The crucial features are 2 GHz AMD Athlon 64 X2 3800+ dual core 3 GIG ram. Windows 7 64-bit JDK 1.6.0_18 64 bit. SATA-3 7200 RPM disk It is a simple Java program you can run without any fuss. I still have to do a few experiments to see how best to allocate RAM between the BufferedOutStream and the BufferedWriter. -- Roedy Green Canadian Mind Products http://mindprod.com When a newbie asks for help tracking a bug in a code snippet, the problem is usually is the code he did not post, hence the value of an SSCCE. see http://mindprod.com/jgloss/sscce.html
From: Roedy Green on 20 Feb 2010 17:27 On Sat, 20 Feb 2010 13:20:16 -0800, Roedy Green <see_website(a)mindprod.com.invalid> wrote, quoted or indirectly quoted someone who said : >Code is posted at >https://wush.net/websvn/mindprod/filedetails.php?repname=mindprod&path=%2Fcom%2Fmindprod%2Fexample%2FTestBuffered.java Turns out giving 25% of the space to BufferedOutputStream and 50% of space to BufferedInputStream is optimal. Speeds are in seconds averaged over 3 trials using 104,857,600 character files and 65,536 character buffers. BufferedWriter 4.37 seconds BufferedOutputStream 24.12 seconds W O R S T DoubleBufferedWriter 10% to BufferedOutputStream 4.00 seconds DoubleBufferedWriter 25% to BufferedOutputStream 3.75 seconds B E S T DoubleBufferedWriter 50% to BufferedOutputStream 3.86 seconds DoubleBufferedWriter 75% to BufferedOutputStream 3.87 seconds BufferedReader 4.10 seconds BufferedInputStream 14.81 seconds DoubleBufferedReader 10% to BufferedInputStream 3.96 seconds DoubleBufferedReader 25% to BufferedInputStream 4.03 seconds DoubleBufferedReader 50% to BufferedInputStream 3.88 seconds B E S T DoubleBufferedReader 75% to BufferedInputStream 3.94 seconds -- Roedy Green Canadian Mind Products http://mindprod.com When a newbie asks for help tracking a bug in a code snippet, the problem is usually is the code he did not post, hence the value of an SSCCE. see http://mindprod.com/jgloss/sscce.html
From: Roedy Green on 20 Feb 2010 21:10 >Code is posted at >https://wush.net/websvn/mindprod/filedetails.php?repname=mindprod&path=%2Fcom%2Fmindprod%2Fexample%2FTestBuffered.java Sun and Jet agree that using a BufferedOutputStream is worst, but disagree on what is best. SUN JVM 1.6.0_18 RESULTS Speeds are in seconds averaged over 3 trials using 104,857,600 character files and 65,536 character buffers. BufferedWriter 4.31 seconds BufferedOutputStream 22.18 seconds W O R S T DoubleBufferedWriter 10% to BufferedOutputStream 4.03 seconds DoubleBufferedWriter 25% to BufferedOutputStream 3.65 seconds B E S T DoubleBufferedWriter 50% to BufferedOutputStream 3.82 seconds DoubleBufferedWriter 75% to BufferedOutputStream 3.68 seconds BufferedReader 3.94 seconds BufferedInputStream 14.11 seconds W O R S T DoubleBufferedReader 10% to BufferedInputStream 4.02 seconds DoubleBufferedReader 25% to BufferedInputStream 3.82 seconds DoubleBufferedReader 50% to BufferedInputStream 3.77 seconds B E S T DoubleBufferedReader 75% to BufferedInputStream 3.81 seconds JET RESULTS Speeds are in seconds averaged over 3 trials using 104,857,600 character files and 65,536 character buffers. BufferedWriter 4.76 seconds BufferedOutputStream 129.08 seconds W O R S T DoubleBufferedWriter 10% to BufferedOutputStream 7.10 seconds DoubleBufferedWriter 25% to BufferedOutputStream 4.91 seconds DoubleBufferedWriter 50% to BufferedOutputStream 4.64 seconds DoubleBufferedWriter 75% to BufferedOutputStream 4.36 seconds B E S T BufferedReader 5.08 seconds BufferedInputStream 109.91 seconds W O R S T DoubleBufferedReader 10% to BufferedInputStream 16.01 seconds DoubleBufferedReader 25% to BufferedInputStream 5.11 seconds DoubleBufferedReader 50% to BufferedInputStream 5.09 seconds DoubleBufferedReader 75% to BufferedInputStream 5.01 seconds B E S T -- Roedy Green Canadian Mind Products http://mindprod.com When a newbie asks for help tracking a bug in a code snippet, the problem is usually is the code he did not post, hence the value of an SSCCE. see http://mindprod.com/jgloss/sscce.html
From: Roedy Green on 20 Feb 2010 22:30 >Code is posted at >https://wush.net/websvn/mindprod/filedetails.php?repname=mindprod&path=%2Fcom%2Fmindprod%2Fexample%2FTestBuffered.java For future reference this BufferedWriter vs BufferedOutputStream stuff is documented at http://mindprod.com/jgloss/buffer.html#WRITERVSOUTPUTSTREAM -- Roedy Green Canadian Mind Products http://mindprod.com When a newbie asks for help tracking a bug in a code snippet, the problem is usually is the code he did not post, hence the value of an SSCCE. see http://mindprod.com/jgloss/sscce.html
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Don't know how to create a project correctly. Next: J2ME Development on Linux |