Bug 20791 - Use of BufferedReader may improve preformance
Summary: Use of BufferedReader may improve preformance
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P2 enhancement (vote)
Target Milestone: 2.1 M4   Edit
Assignee: Andrew Irvine CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2002-06-21 09:44 EDT by Randy Giffen CLA
Modified: 2002-12-17 18:19 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Randy Giffen CLA 2002-06-21 09:44:13 EDT
There are several places in our code where we use InputStreamReader.
The comment for this class states:

 * <p> For top efficiency, consider wrapping an InputStreamReader within a
 * BufferedReader.  For example:
 *
 * <pre>
 * BufferedReader in
 *   = new BufferedReader(new InputStreamReader(System.in));
 * </pre>

See

load(String) - org.eclipse.jface.dialogs.DialogSettings
loadAssociations() - org.eclipse.ui.internal.registry.EditorRegistry (2 
matches)
loadCustomPersp(PerspectiveDescriptor) - org.eclipse.ui.internal.Perspective
loadDialogSettings() - org.eclipse.ui.plugin.AbstractUIPlugin
openPreviousWorkbenchState() - org.eclipse.ui.internal.Workbench
PerspectiveDescriptor(File) - 
org.eclipse.ui.internal.registry.PerspectiveDescriptor
restoreState() - org.eclipse.ui.internal.WorkingSetManager
Comment 1 Nick Edgar CLA 2002-06-21 12:22:35 EDT
It would be good to have some numbers backing this up.
Comment 2 Jeff McAffer CLA 2002-11-11 18:51:19 EST
Performance varies depending on the disk system (e.g., networked drives are 
horrible) and whether or not the file is in the disk cache.  On my TP with the 
file in the cache, buffered is more than 2x faster than non-buffered.  The 
result is more impressive when the file is not in the cache.

Core and JDT did a pass of making everything buffered in the 1.0 timeframe.  
Eventhough the volume of data read by the UI is probably not that great the 
change is simple and low risk.

See the test code below.  For a 3.5MB file the numbers are:

testing...
non buffered 1713
buffered 761



import java.io.*;

public class BufferTest {

public static void main(String[] args) throws Exception {
	long start = 0;
	System.out.println ("testing...");
	Reader in = new InputStreamReader(new FileInputStream("test"));
	start = System.currentTimeMillis();
	while (in.read() != -1) {}
	System.out.println ("non buffered " + (System.currentTimeMillis() - 
start));
	in.close();

	in = new BufferedReader (new InputStreamReader(new FileInputStream
("test")));
	start = System.currentTimeMillis();
	while (in.read() != -1) {}
	System.out.println ("buffered " + (System.currentTimeMillis() - start));
	in.close();
	}
}

Comment 3 Nick Edgar CLA 2002-11-12 20:58:07 EST
Should fix for 2.1.
There may be others now too.
Comment 4 Andrew Irvine CLA 2002-11-19 16:44:04 EST
BufferedReader wraps InputStreamReader in 20021120 build
Comment 5 Nick Edgar CLA 2002-11-22 11:31:09 EST
Note that BufferedReaders need not be used when using a StringReader, since 
the reading is all done in memory anyway.
Noticed this in the changes to EditorRegistry.  There may be other places.
Comment 6 Andrew Irvine CLA 2002-11-22 13:41:21 EST
Fixed in 20021123 build
Comment 7 Knut Radloff CLA 2002-12-17 18:19:27 EST
Verified fixed in build 20021216. However, there are new places that don't use 
BufferedReader. Opened bug 28585.