summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten <mkersten>2003-09-05 06:47:41 +0000
committermkersten <mkersten>2003-09-05 06:47:41 +0000
commit47d26980a60101acbfe14f094eb3ff26493a6592 (patch)
tree7b24a4a03b74f8e4190d33bd6fea7f1b369392d7
parente9e87aa0d512e3254dbc69705d148c89de890730 (diff)
downloadaspectj-47d26980a60101acbfe14f094eb3ff26493a6592.tar.gz
aspectj-47d26980a60101acbfe14f094eb3ff26493a6592.zip
Added model building performance test.
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AjdeTests.java1
-rw-r--r--ajde/testsrc/org/aspectj/ajde/ModelPerformanceTest.java67
-rw-r--r--ajde/testsrc/org/aspectj/ajde/StructureModelTest.java8
3 files changed, 74 insertions, 2 deletions
diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
index e6be0bc12..712be101f 100644
--- a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
+++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
@@ -30,6 +30,7 @@ public class AjdeTests extends TestCase {
suite.addTestSuite(AsmDeclarationsTest.class);
suite.addTestSuite(AsmRelationshipsTest.class);
suite.addTestSuite(ResourceCopyTestCase.class);
+ suite.addTestSuite(ModelPerformanceTest.class);
//$JUnit-END$
return suite;
diff --git a/ajde/testsrc/org/aspectj/ajde/ModelPerformanceTest.java b/ajde/testsrc/org/aspectj/ajde/ModelPerformanceTest.java
new file mode 100644
index 000000000..1734c4211
--- /dev/null
+++ b/ajde/testsrc/org/aspectj/ajde/ModelPerformanceTest.java
@@ -0,0 +1,67 @@
+/* *******************************************************************
+ * Copyright (c) 2003 Contributors.
+ * 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:
+ * Mik Kersten initial implementation
+ * ******************************************************************/
+
+package org.aspectj.ajde;
+
+/**
+ * @author Mik Kersten
+ */
+public class ModelPerformanceTest extends AjdeTestCase {
+
+ private final String CONFIG_FILE_PATH = "../examples/spacewar/spacewar/debug.lst";
+
+ public ModelPerformanceTest(String name) {
+ super(name);
+ }
+
+ public static void main(String[] args) {
+ junit.swingui.TestRunner.run(ModelPerformanceTest.class);
+ }
+
+ /**
+ * Assert that a compile that includes building the structure model
+ * adds an acceptable percentage of overhead.
+ *
+ * Does a few initial builds to minimize caching effects.
+ */
+ public void testRelativeToNoModel() {
+ timedBuild(true);
+ timedBuild(false);
+ timedBuild(true);
+
+ long rawBuildTime = timedBuild(false);
+ long modelBuildTime = timedBuild(true);
+ float overhead = (float)modelBuildTime / (float)rawBuildTime;
+
+ assertTrue(overhead < 1.3);
+// System.err.println("> overhead: " + overhead);
+ }
+
+ public long timedBuild(boolean buildModel) {
+ long startTime = System.currentTimeMillis();
+ doSynchronousBuild(CONFIG_FILE_PATH);
+ Ajde.getDefault().getBuildManager().setBuildModelMode(buildModel);
+ long endTime = System.currentTimeMillis();
+ return (endTime - startTime);
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp("examples");
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
+
diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
index d8f30c172..74ccceefb 100644
--- a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
+++ b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
@@ -98,8 +98,12 @@ public class StructureModelTest extends AjdeTestCase {
public void testFileNodeFind() throws IOException {
File testFile = openFile("figures-coverage/figures/Main.java");
+
+// System.err.println(((IProgramElement)((IProgramElement)Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot().getChildren().get(0)).getChildren().get(3)).getSourceLocation().getSourceFile().getAbsolutePath());
+// System.err.println(testFile.getAbsolutePath());
+
IProgramElement node = Ajde.getDefault().getStructureModelManager().getHierarchy().findElementForSourceLine(
- testFile.getCanonicalPath(), 1);
+ testFile.getAbsolutePath(), 1);
assertTrue("find result", node != null) ;
assertEquals("find result has children", 3, node.getChildren().size()) ;
IProgramElement pNode = (IProgramElement)node;
@@ -114,7 +118,7 @@ public class StructureModelTest extends AjdeTestCase {
assertTrue("model exists", model != null);
assertTrue("root exists", model.getRoot() != null);
File testFile = openFile("figures-coverage/figures/Main.java");
- IProgramElement node = model.findElementForSourceLine(testFile.getCanonicalPath(), 11);
+ IProgramElement node = model.findElementForSourceLine(testFile.getAbsolutePath(), 11);
assertTrue("find result", node != null);
IProgramElement pNode = (IProgramElement)((IProgramElement)node).getParent();
if (null == pNode) {