Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcvs2svn2004-11-01 22:43:54 +0000
committercvs2svn2004-11-01 22:43:54 +0000
commit5491e819f8f0c09cc3d363884ba4eeb3fdafcf3a (patch)
treed2a84cf66fcaa7dc1d802c6344c6079125b614c0
parent9dd973d1c3f3f9a6dafe0d097e5624212589b1c0 (diff)
downloadeclipse.jdt.debug-5491e819f8f0c09cc3d363884ba4eeb3fdafcf3a.tar.gz
eclipse.jdt.debug-5491e819f8f0c09cc3d363884ba4eeb3fdafcf3a.tar.xz
eclipse.jdt.debug-5491e819f8f0c09cc3d363884ba4eeb3fdafcf3a.zip
This commit was manufactured by cvs2svn to create branch 'R3_0_maintenance'.
Cherrypick from master 2004-11-01 22:43:52 UTC Darin Wright <darin> 'remove step test from finger print': org.eclipse.jdt.debug.tests/testprograms/PerfLoop.java org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugPerformanceTest.java org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/DebugSuite.java org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/PerformanceSuite.java org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfConditionalBreakpointsTests.java org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfSteppingTests.java org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/performance/JavaApplicationStatusHandler.java org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/performance/OpenLaunchConfigurationDialogTests.java
-rw-r--r--org.eclipse.jdt.debug.tests/testprograms/PerfLoop.java25
-rw-r--r--org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugPerformanceTest.java112
-rw-r--r--org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/DebugSuite.java76
-rw-r--r--org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/PerformanceSuite.java43
-rw-r--r--org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfConditionalBreakpointsTests.java79
-rw-r--r--org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfSteppingTests.java48
-rw-r--r--org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/performance/JavaApplicationStatusHandler.java28
-rw-r--r--org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/performance/OpenLaunchConfigurationDialogTests.java65
8 files changed, 476 insertions, 0 deletions
diff --git a/org.eclipse.jdt.debug.tests/testprograms/PerfLoop.java b/org.eclipse.jdt.debug.tests/testprograms/PerfLoop.java
new file mode 100644
index 000000000..a15c0f9a1
--- /dev/null
+++ b/org.eclipse.jdt.debug.tests/testprograms/PerfLoop.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+import java.util.Vector;
+
+/**
+ * A loop adding to a collection
+ */
+public class PerfLoop {
+
+ public static void main(String[] args) {
+ Vector v = new Vector(200);
+ for (int i = 0; i < 100; i++) {
+ v.add(new Integer(i));
+ }
+ }
+}
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugPerformanceTest.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugPerformanceTest.java
new file mode 100644
index 000000000..950a6766d
--- /dev/null
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugPerformanceTest.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.debug.tests;
+
+import org.eclipse.test.performance.Dimension;
+import org.eclipse.test.performance.Performance;
+import org.eclipse.test.performance.PerformanceMeter;
+
+public class AbstractDebugPerformanceTest extends AbstractDebugTest {
+
+ protected PerformanceMeter fPerformanceMeter;
+
+ /**
+ * Constructs a performance test case with the given name.
+ * @param name the name of the performance test case
+ */
+ public AbstractDebugPerformanceTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Overridden to create a default performance meter for this test case.
+ * @throws Exception
+ */
+ protected void setUp() throws Exception {
+ Performance performance= Performance.getDefault();
+ fPerformanceMeter= performance.createPerformanceMeter(performance.getDefaultScenarioId(this));
+ }
+
+ /**
+ * Overridden to dispose of the performance meter.
+ * @throws Exception
+ */
+ protected void tearDown() throws Exception {
+ fPerformanceMeter.dispose();
+ }
+
+ /**
+ * Mark the scenario of this test case
+ * to be included into the global performance summary. The summary shows
+ * the given dimension of the scenario and labels the scenario with the short name.
+ *
+ * @param shortName a short (shorter than 40 characters) descritive name of the scenario
+ * @param dimension the dimension to show in the summary
+ */
+ public void tagAsGlobalSummary(String shortName, Dimension dimension) {
+ Performance performance= Performance.getDefault();
+ performance.tagAsGlobalSummary(fPerformanceMeter, shortName, new Dimension[] { dimension } );
+ }
+
+ /**
+ * Mark the scenario represented by the given PerformanceMeter
+ * to be included into the global performance summary. The summary shows
+ * the given dimensions of the scenario and labels the scenario with the short name.
+ *
+ * @param shortName a short (shorter than 40 characters) descritive name of the scenario
+ * @param dimensions an array of dimensions to show in the summary
+ */
+ public void tagAsGlobalSummary(String shortName, Dimension[] dimensions) {
+ Performance performance= Performance.getDefault();
+ performance.tagAsGlobalSummary(fPerformanceMeter, shortName, dimensions );
+ }
+
+ /**
+ * Called from within a test case immediately before the code to measure is run.
+ * It starts capturing of performance data.
+ * Must be followed by a call to {@link PerformanceTestCase#stopMeasuring()} before subsequent calls
+ * to this method or {@link PerformanceTestCase#commitMeasurements()}.
+ */
+ protected void startMeasuring() {
+ fPerformanceMeter.start();
+ }
+
+ protected void stopMeasuring() {
+ fPerformanceMeter.stop();
+ }
+
+ protected void commitMeasurements() {
+ fPerformanceMeter.commit();
+ }
+
+ /**
+ * Asserts default properties of the measurements captured for this test case.
+ *
+ * @throws RuntimeException if the properties do not hold
+ */
+ protected void assertPerformance() {
+ Performance.getDefault().assertPerformance(fPerformanceMeter);
+ }
+
+ /**
+ * Asserts that the measurement specified by the given dimension
+ * is within a certain range with respect to some reference value.
+ * If the specified dimension isn't available, the call has no effect.
+ *
+ * @param dim the Dimension to check
+ * @param lowerPercentage a negative number indicating the percentage the measured value is allowed to be smaller than some reference value
+ * @param upperPercentage a positive number indicating the percentage the measured value is allowed to be greater than some reference value
+ * @throws RuntimeException if the properties do not hold
+ */
+ protected void assertPerformanceInRelativeBand(Dimension dim, int lowerPercentage, int upperPercentage) {
+ Performance.getDefault().assertPerformanceInRelativeBand(fPerformanceMeter, dim, lowerPercentage, upperPercentage);
+ }
+}
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/DebugSuite.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/DebugSuite.java
new file mode 100644
index 000000000..e458107c9
--- /dev/null
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/DebugSuite.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.debug.tests;
+
+import java.util.Enumeration;
+
+import junit.framework.Test;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Debug test suite framework that runs test in a non UI thread.
+ */
+public abstract class DebugSuite extends TestSuite {
+
+ /**
+ * Flag that indicates test are in progress
+ */
+ protected boolean fTesting = true;
+
+
+ /**
+ * Construct the test suite.
+ */
+ public DebugSuite() {
+ }
+
+ /**
+ * Runs the tests and collects their result in a TestResult.
+ * The debug tests cannot be run in the UI thread or the event
+ * waiter blocks the UI when a resource changes.
+ */
+ public void run(final TestResult result) {
+ final Display display = Display.getCurrent();
+ Thread thread = null;
+ try {
+ Runnable r = new Runnable() {
+ public void run() {
+ for (Enumeration e= tests(); e.hasMoreElements(); ) {
+ if (result.shouldStop() )
+ break;
+ Test test= (Test)e.nextElement();
+ runTest(test, result);
+ }
+ fTesting = false;
+ display.wake();
+ }
+ };
+ thread = new Thread(r);
+ thread.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ while (fTesting) {
+ try {
+ if (!display.readAndDispatch())
+ display.sleep();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
+
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/PerformanceSuite.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/PerformanceSuite.java
new file mode 100644
index 000000000..91ac94160
--- /dev/null
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/PerformanceSuite.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.debug.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.jdt.debug.tests.performance.PerfConditionalBreakpointsTests;
+import org.eclipse.jdt.debug.tests.performance.PerfSteppingTests;
+
+/**
+ * Tests for integration and nightly builds.
+ */
+public class PerformanceSuite extends DebugSuite {
+
+ /**
+ * Returns the suite. This is required to
+ * use the JUnit Launcher.
+ */
+ public static Test suite() {
+ return new PerformanceSuite();
+ }
+
+ /**
+ * Construct the test suite.
+ */
+ public PerformanceSuite() {
+ addTest(new TestSuite(ProjectCreationDecorator.class));
+
+ addTest(new TestSuite(PerfConditionalBreakpointsTests.class));
+ addTest(new TestSuite(PerfSteppingTests.class));
+
+ }
+}
+
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfConditionalBreakpointsTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfConditionalBreakpointsTests.java
new file mode 100644
index 000000000..e7f2ea6c7
--- /dev/null
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfConditionalBreakpointsTests.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.debug.tests.performance;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaPrimitiveValue;
+import org.eclipse.jdt.debug.core.IJavaStackFrame;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.debug.tests.AbstractDebugPerformanceTest;
+import org.eclipse.test.performance.Dimension;
+
+/**
+ * Tests performance of conditional breakpoints.
+ */
+public class PerfConditionalBreakpointsTests extends
+ AbstractDebugPerformanceTest {
+
+ public PerfConditionalBreakpointsTests(String name) {
+ super(name);
+ }
+
+ public void testConditionalBreakpoint() throws Exception {
+ String typeName = "PerfLoop";
+ IJavaLineBreakpoint bp = createConditionalLineBreakpoint(22, typeName, "i == 99", true);
+
+ List threads= new ArrayList();
+ try {
+
+ //cold launch, open editor etc.
+ IJavaThread thread = launchToLineBreakpoint(typeName, bp);
+ threads.add(thread);
+ tagAsGlobalSummary("Conditional Breakpoint", Dimension.CPU_TIME);
+ for (int i = 0; i < 5; i++) {
+ try {
+ startMeasuring();
+ thread = launchToLineBreakpoint(typeName, bp);
+ stopMeasuring();
+ } finally {
+ threads.add(thread);
+ }
+ }
+
+ commitMeasurements();
+ assertPerformance();
+
+ //verify actually stopping at the correct location
+ IJavaStackFrame frame = (IJavaStackFrame) thread.getTopStackFrame();
+ IVariable var = frame.findVariable("i");
+ assertNotNull("Could not find variable 'i'", var);
+
+ IJavaPrimitiveValue value = (IJavaPrimitiveValue) var.getValue();
+ assertNotNull("variable 'i' has no value", value);
+ int iValue = value.getIntValue();
+ assertEquals("value of 'i' incorrect", 99, iValue);
+ bp.delete();
+ } finally {
+ Iterator iter= threads.iterator();
+ while (iter.hasNext()) {
+ IJavaThread thread = (IJavaThread) iter.next();
+ terminateAndRemove(thread);
+ }
+
+ removeAllBreakpoints();
+ }
+ }
+}
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfSteppingTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfSteppingTests.java
new file mode 100644
index 000000000..b94bc700d
--- /dev/null
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfSteppingTests.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.debug.tests.performance;
+
+import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaStackFrame;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.debug.tests.AbstractDebugPerformanceTest;
+
+/**
+ * Tests performance of stepping.
+ */
+public class PerfSteppingTests extends AbstractDebugPerformanceTest {
+
+ public PerfSteppingTests(String name) {
+ super(name);
+ }
+
+ public void testRapidStepping() throws Exception {
+ String typeName = "PerfLoop";
+ IJavaLineBreakpoint bp = createLineBreakpoint(20, typeName);
+
+ IJavaThread thread= null;
+ try {
+ thread= launchToLineBreakpoint(typeName, bp);
+
+ IJavaStackFrame frame = (IJavaStackFrame)thread.getTopStackFrame();
+ for (int i = 0; i < 100; i++) {
+ startMeasuring();
+ stepOver(frame);
+ stopMeasuring();
+ }
+ commitMeasurements();
+ assertPerformance();
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/performance/JavaApplicationStatusHandler.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/performance/JavaApplicationStatusHandler.java
new file mode 100644
index 000000000..63bd420e3
--- /dev/null
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/performance/JavaApplicationStatusHandler.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.debug.tests.ui.performance;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.debug.core.IStatusHandler;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+
+public class JavaApplicationStatusHandler implements IStatusHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object)
+ */
+ public Object handleStatus(IStatus status, Object source) throws CoreException {
+ ILaunchConfigurationDialog dialog = (ILaunchConfigurationDialog)source;
+ dialog.setActiveTab(3);
+ return null;
+ }
+}
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/performance/OpenLaunchConfigurationDialogTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/performance/OpenLaunchConfigurationDialogTests.java
new file mode 100644
index 000000000..6b125be8a
--- /dev/null
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/performance/OpenLaunchConfigurationDialogTests.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.debug.tests.ui.performance;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog;
+import org.eclipse.jdt.debug.tests.AbstractDebugPerformanceTest;
+import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+public class OpenLaunchConfigurationDialogTests extends AbstractDebugPerformanceTest {
+
+ public OpenLaunchConfigurationDialogTests(String name) {
+ super(name);
+ }
+
+ public static String fgIdentifier= "org.eclipse.jdt.launching.localJavaApplication";
+
+ public void testOpenJavaProgramLaunchConfigurationDialog1() {
+ // cold run
+ ILaunchConfiguration config = getLaunchConfiguration("Breakpoints");
+ IStructuredSelection selection= new StructuredSelection(config);
+ for (int i = 0; i < 100; i++) {
+ openLCD(selection, fgIdentifier);
+ }
+
+ commitMeasurements();
+ assertPerformance();
+ }
+
+ public void testOpenJavaProgramLaunchConfigurationDialog2() {
+ // warm run..depends on testOpenJavaProgramLaunchConfigurationDialog1 for cold start
+ ILaunchConfiguration config = getLaunchConfiguration("Breakpoints");
+ IStructuredSelection selection = new StructuredSelection(config);
+ openLCD(selection, fgIdentifier);
+ }
+
+ private void openLCD(final IStructuredSelection selection, final String groupIdentifier) {
+
+ //set a status to go to the classpath tab
+ IStatus status = new Status(IStatus.INFO, IJavaDebugUIConstants.PLUGIN_ID, 1000, "", null); //$NON-NLS-1$
+ LaunchConfigurationsDialog dialog= new LaunchConfigurationsDialog(DebugUIPlugin.getShell(), DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(groupIdentifier));
+ dialog.setBlockOnOpen(false);
+ dialog.setOpenMode(LaunchConfigurationsDialog.LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_SELECTION);
+ dialog.setInitialSelection(selection);
+ dialog.setInitialStatus(status);
+ startMeasuring();
+ dialog.open();
+ dialog.close();
+ stopMeasuring();
+ }
+}

Back to the top