Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/org.eclipse.compare.tests/plugin.xml1
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/PerformanceTestSuite.java28
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/RangeDifferencerTest.java90
-rw-r--r--tests/org.eclipse.compare.tests/test.xml21
4 files changed, 138 insertions, 2 deletions
diff --git a/tests/org.eclipse.compare.tests/plugin.xml b/tests/org.eclipse.compare.tests/plugin.xml
index 1e4dce75c..0a1cb4fd7 100644
--- a/tests/org.eclipse.compare.tests/plugin.xml
+++ b/tests/org.eclipse.compare.tests/plugin.xml
@@ -20,6 +20,7 @@
<import plugin="org.eclipse.jface"/>
<import plugin="org.eclipse.jdt.junit"/>
<import plugin="org.eclipse.core.runtime"/>
+ <import plugin="org.eclipse.test.performance"/>
</requires>
</plugin>
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/PerformanceTestSuite.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/PerformanceTestSuite.java
new file mode 100644
index 000000000..4416e3eeb
--- /dev/null
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/PerformanceTestSuite.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.tests.performance;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @since 3.1
+ */
+public class PerformanceTestSuite extends TestSuite {
+
+ public static Test suite() {
+ TestSuite suite= new TestSuite("Compare performance tests"); //$NON-NLS-1$
+ //$JUnit-BEGIN$
+ suite.addTestSuite(RangeDifferencerTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+}
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/RangeDifferencerTest.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/RangeDifferencerTest.java
new file mode 100644
index 000000000..ff211394a
--- /dev/null
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/RangeDifferencerTest.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.tests.performance;
+
+import org.eclipse.compare.contentmergeviewer.ITokenComparator;
+import org.eclipse.compare.internal.DocLineComparator;
+import org.eclipse.compare.rangedifferencer.RangeDifference;
+import org.eclipse.compare.rangedifferencer.RangeDifferencer;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.test.performance.PerformanceTestCase;
+
+
+public class RangeDifferencerTest extends PerformanceTestCase {
+
+ public RangeDifferencerTest(String name) {
+ super(name);
+ }
+
+ /*
+ * Creates document with 5000 lines.
+ * Parameter code determines where additional lines are added.
+ */
+ private IDocument createDocument(int code) {
+ StringBuffer sb= new StringBuffer();
+ for (int i= 0; i < 5000; i++) {
+ sb.append("line "); //$NON-NLS-1$
+ sb.append(Integer.toString(i));
+ sb.append('\n');
+
+ int mod= i % 10;
+ switch (code) {
+ case 1:
+ if (mod == 1)
+ sb.append("outgoing\n"); //$NON-NLS-1$
+ if (mod == 4)
+ sb.append("conflict1\n"); //$NON-NLS-1$
+ break;
+ case 2:
+ if (mod == 7)
+ sb.append("incoming\n"); //$NON-NLS-1$
+ if (mod == 4)
+ sb.append("conflict2\n"); //$NON-NLS-1$
+ break;
+ }
+ }
+ return new Document(sb.toString());
+ }
+
+ public void testLargeDocument() {
+
+ ITokenComparator ancestor= new DocLineComparator(createDocument(0), null, false);
+ ITokenComparator left= new DocLineComparator(createDocument(1), null, false);
+ ITokenComparator right= new DocLineComparator(createDocument(2), null, false);
+
+ RangeDifference[] diffs= null;
+
+ // a warm up run
+ diffs= RangeDifferencer.findRanges(new NullProgressMonitor(), ancestor, left, right);
+
+ // assert that result correct
+ for (int i= 0; i < diffs.length-6; i+= 6) {
+ assertEquals(diffs[i+0].kind(), RangeDifference.NOCHANGE);
+ assertEquals(diffs[i+1].kind(), RangeDifference.LEFT);
+ assertEquals(diffs[i+2].kind(), RangeDifference.NOCHANGE);
+ assertEquals(diffs[i+3].kind(), RangeDifference.CONFLICT);
+ assertEquals(diffs[i+4].kind(), RangeDifference.NOCHANGE);
+ assertEquals(diffs[i+5].kind(), RangeDifference.RIGHT);
+ }
+
+ // now do 3 performance runs
+ for (int count= 0; count < 3; count++) {
+ startMeasuring();
+ RangeDifferencer.findRanges(new NullProgressMonitor(), ancestor, left, right);
+ stopMeasuring();
+ }
+
+ commitMeasurements();
+ assertPerformance();
+ }
+}
diff --git a/tests/org.eclipse.compare.tests/test.xml b/tests/org.eclipse.compare.tests/test.xml
index 972881c98..254b3fa69 100644
--- a/tests/org.eclipse.compare.tests/test.xml
+++ b/tests/org.eclipse.compare.tests/test.xml
@@ -30,6 +30,17 @@
</ant>
</target>
+ <!-- This target defines the performance tests that need to be run. -->
+ <target name="performance-suite">
+ <property name="compare-performance-folder" value="${eclipse-home}/compare_performance_folder"/>
+ <delete dir="${compare-performance-folder}" quiet="true"/>
+ <ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="data-dir" value="${compare-performance-folder}"/>
+ <property name="plugin-name" value="${plugin-name}"/>
+ <property name="classname" value="org.eclipse.compare.tests.performance.PerformanceTestSuite"/>
+ </ant>
+ </target>
+
<!-- This target holds code to cleanup the testing environment after -->
<!-- after all of the tests have been run. You can use this target to -->
<!-- delete temporary files that have been created. -->
@@ -45,7 +56,13 @@
</ant>
</target>
- <!-- This target runs the performance test suites. -->
- <target name="performance">
+ <!-- This target runs the performance test suite. Any actions that need to happen -->
+ <!-- after all the tests have been run should go here. -->
+ <target name="performance" depends="init,performance-suite,cleanup">
+ <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="includes" value="org*.xml"/>
+ <property name="output-file" value="${plugin-name}.xml"/>
+ </ant>
</target>
+
</project>

Back to the top