]> source.dussan.org Git - aspectj.git/commitdiff
Added model building performance test.
authormkersten <mkersten>
Fri, 5 Sep 2003 06:47:41 +0000 (06:47 +0000)
committermkersten <mkersten>
Fri, 5 Sep 2003 06:47:41 +0000 (06:47 +0000)
ajde/testsrc/org/aspectj/ajde/AjdeTests.java
ajde/testsrc/org/aspectj/ajde/ModelPerformanceTest.java [new file with mode: 0644]
ajde/testsrc/org/aspectj/ajde/StructureModelTest.java

index e6be0bc1266c95cf489bee41198af596174cb645..712be101fa4eff21077084e355f18462232db578 100644 (file)
@@ -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 (file)
index 0000000..1734c42
--- /dev/null
@@ -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();
+       }
+
+}
+
index d8f30c172b9363802b98bf284deab8b33c197742..74ccceefbe792f38917ddb45a3e86bc55fde5e53 100644 (file)
@@ -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) {