Bug 78166 - [performance test] console
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ProjectCreationDecorator.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ProjectCreationDecorator.java
index 040c702..0daef59 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ProjectCreationDecorator.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ProjectCreationDecorator.java
@@ -13,6 +13,7 @@
import java.io.File;
import java.util.HashMap;
import java.util.Map;
+
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -23,6 +24,7 @@
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.debug.core.JDIDebugModel;
@@ -35,6 +37,9 @@
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.ui.IPerspectiveDescriptor;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
/**
* Test to close the workbench, since debug tests do not run in the UI
@@ -123,6 +128,8 @@
createLaunchConfiguration("ArrayTests");
createLaunchConfiguration("PerfLoop");
createLaunchConfiguration("Console80Chars");
+ createLaunchConfiguration("ConsoleStackTrace");
+ createLaunchConfiguration("ConsoleVariableLineLength");
}
/**
@@ -187,4 +194,15 @@
JavaProjectHelper.addVariableEntry(project, new Path(JavaRuntime.JRELIB_VARIABLE), new Path(JavaRuntime.JRESRC_VARIABLE), new Path(JavaRuntime.JRESRCROOT_VARIABLE));
}
+
+ public void testPerspectiveSwtich() {
+ DebugUIPlugin.getStandardDisplay().syncExec(new Runnable() {
+ public void run() {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IPerspectiveDescriptor descriptor = workbench.getPerspectiveRegistry().findPerspectiveWithId(IDebugUIConstants.ID_DEBUG_PERSPECTIVE);
+ workbench.getActiveWorkbenchWindow().getActivePage().setPerspective(descriptor);
+ }
+ }
+ );
+ }
}
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfConsoleTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfConsoleTests.java
index f37feff..b4fcc65 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfConsoleTests.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfConsoleTests.java
@@ -12,15 +12,25 @@
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
-import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
+import org.eclipse.debug.ui.console.IConsole;
+import org.eclipse.debug.ui.console.IConsoleLineTrackerExtension;
+import org.eclipse.jdt.debug.testplugin.ConsoleLineTracker;
import org.eclipse.jdt.debug.tests.AbstractDebugPerformanceTest;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IRegion;
/**
* Tests performance of the console.
*/
-public class PerfConsoleTests extends AbstractDebugPerformanceTest {
+public class PerfConsoleTests extends AbstractDebugPerformanceTest implements IConsoleLineTrackerExtension {
+
+ protected boolean fStarted = false;
+ protected boolean fStopped = false;
+ protected Object fLock = new Object();
public PerfConsoleTests(String name) {
super(name);
@@ -33,25 +43,124 @@
public void testDefault100k() throws Exception {
runFixedWidthTest(100000);
}
+
+ public void testStackTrace10k() throws Exception {
+ runStackTrace(5000); // 2 lines * 5000 repeats = 10,000 hyperlinks
+ }
+
+ public void testStackTrace100k() throws Exception {
+ runStackTrace(50000); // 2 lines * 50,000 repeats = 100,000 hyperlinks
+ }
+
+ public void testVarLength10k() throws Exception {
+ runVariableLength(2500); // 4 lines * 2500 repeats = 10,000 lines
+ }
+
+ public void testVarLength100k() throws Exception {
+ runVariableLength(25000); // 4 lines * 25,000 repeats = 100,000 lines
+ }
+ protected void setUp() throws Exception {
+ super.setUp();
+ fStarted = false;
+ fStopped = false;
+ ConsoleLineTracker.setDelegate(this);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ ConsoleLineTracker.setDelegate(null);
+ }
+
protected void runFixedWidthTest(int lines) throws Exception {
String typeName = "Console80Chars";
ILaunchConfiguration configuration = getLaunchConfiguration(typeName);
ILaunchConfigurationWorkingCopy workingCopy = configuration.getWorkingCopy();
workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, Integer.toString(lines));
- IJavaLineBreakpoint bp = createLineBreakpoint(18, typeName);
- createLineBreakpoint(23, typeName);
- IJavaThread thread = null;
+ workingCopy.launch(ILaunchManager.RUN_MODE, null, false);
+ synchronized (fLock) {
+ if (!fStopped) {
+ fLock.wait(360000);
+ }
+ }
+ assertTrue("Never received 'start' notification", fStarted);
+ assertTrue("Never received 'stopped' notification", fStopped);
+ commitMeasurements();
+ assertPerformance();
+ }
+
+ protected void runStackTrace(int repeats) throws Exception {
+ String typeName = "ConsoleStackTrace";
+ ILaunchConfiguration configuration = getLaunchConfiguration(typeName);
+ ILaunchConfigurationWorkingCopy workingCopy = configuration.getWorkingCopy();
+ workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, Integer.toString(repeats));
+ workingCopy.launch(ILaunchManager.RUN_MODE, null, false);
+ synchronized (fLock) {
+ if (!fStopped) {
+ fLock.wait(360000);
+ }
+ }
+ assertTrue("Never received 'start' notification", fStarted);
+ assertTrue("Never received 'stopped' notification", fStopped);
+ commitMeasurements();
+ assertPerformance();
+ }
+
+ protected void runVariableLength(int repeats) throws Exception {
+ String typeName = "ConsoleVariableLineLength";
+ ILaunchConfiguration configuration = getLaunchConfiguration(typeName);
+ ILaunchConfigurationWorkingCopy workingCopy = configuration.getWorkingCopy();
+ workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, Integer.toString(repeats));
+ IPreferenceStore debugUIPreferences = DebugUIPlugin.getDefault().getPreferenceStore();
try {
- thread= launchAndSuspend(workingCopy);
- startMeasuring();
- thread = resume(thread, 360000);
- stopMeasuring();
+ debugUIPreferences.setValue(IDebugPreferenceConstants.CONSOLE_WRAP, true);
+ workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, Integer.toString(repeats));
+ workingCopy.launch(ILaunchManager.RUN_MODE, null, false);
+ synchronized (fLock) {
+ if (!fStopped) {
+ fLock.wait(360000);
+ }
+ }
+ assertTrue("Never received 'start' notification", fStarted);
+ assertTrue("Never received 'stopped' notification", fStopped);
commitMeasurements();
assertPerformance();
} finally {
- terminateAndRemove(thread);
- removeAllBreakpoints();
+ debugUIPreferences.setValue(IDebugPreferenceConstants.CONSOLE_WRAP, false);
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.console.IConsoleLineTrackerExtension#consoleClosed()
+ */
+ public void consoleClosed() {
+ stopMeasuring();
+ synchronized (fLock) {
+ fStopped = true;
+ fLock.notifyAll();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.console.IConsoleLineTracker#init(org.eclipse.debug.ui.console.IConsole)
+ */
+ public void init(IConsole console) {
+ fStarted = true;
+ startMeasuring();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.console.IConsoleLineTracker#lineAppended(org.eclipse.jface.text.IRegion)
+ */
+ public void lineAppended(IRegion line) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.console.IConsoleLineTracker#dispose()
+ */
+ public void dispose() {
+ }
}
\ No newline at end of file