Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

IncrementalPerformanceTests.java 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /********************************************************************
  2. * Copyright (c) 2008 Contributors. All rights reserved.
  3. * This program and the accompanying materials are made available
  4. * under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution and is available at
  6. * http://eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * Andy Clement initial implementation
  10. *******************************************************************/
  11. package org.aspectj.systemtest.incremental.tools;
  12. import java.io.IOException;
  13. import org.aspectj.ajde.core.ICompilerConfiguration;
  14. /**
  15. * Testing the performance of incremental compilation as it would be in AJDT.
  16. *
  17. * @author AndyClement
  18. */
  19. public class IncrementalPerformanceTests extends AbstractMultiProjectIncrementalAjdeInteractionTestbed {
  20. /**
  21. * Build a project of 64 source files and no aspects.<br>
  22. * <ul>
  23. * <li>First build is a full build.
  24. * <li>Second build is an incremental build with no changes at all.
  25. * <li>Third build is an incremental build with just a source file touched (not changed).
  26. * </ul>
  27. *
  28. * <p>
  29. * 162-dev, 28Aug08 times: Thinkpad T61p: 3203/3140/3234/3156 173/172/172/172 313/297/297/312
  30. */
  31. public void testBuildingProject64Files() {
  32. String proj = "Proj64";
  33. // A full build:
  34. initialiseProject(proj);
  35. build(proj);
  36. checkWasFullBuild();
  37. long fullbuildtime = getTimeTakenForBuild(proj);
  38. System.out.println("Full build time: " + fullbuildtime + "ms");
  39. // An incremental build with no source file changes at all. What should happen?
  40. // We need to determine that nothing has to be done as fast as possible, this is all about
  41. // determining from the configuration that nothing has changed and returning as fast as possible. Any
  42. // delays here are unnecessary burden that will hurt every other kind of compilation.
  43. build(proj);
  44. checkWasntFullBuild();
  45. checkCompileWeaveCount(proj, 0, 0);
  46. long nochangebuild = getTimeTakenForBuild(proj);
  47. System.out.println("Incr build time for no changes at all: " + nochangebuild + "ms");
  48. // An incremental build with no source file changes at all *and* we tell the compiler there are
  49. // no source changes (so it doesn't need to check timestamps). super fast
  50. addProjectSourceFileChanged(proj, null);
  51. build(proj);
  52. checkWasntFullBuild();
  53. checkCompileWeaveCount(proj, 0, 0);
  54. long nochangebuildandDoTellCompiler = getTimeTakenForBuild(proj);
  55. System.out.println("Incr build time for no changes at all and telling the compiler that: " + nochangebuildandDoTellCompiler
  56. + "ms");
  57. // Now we touch a file (C0.java) and call build. What should happen?
  58. // We need to determine what has changed, we'll do that by walking over the set of input files and
  59. // checking their last modified stamps. So although we won't rebuild a buildConfig object, we will
  60. // call lastModifiedTime() a lot to determine which file has changed.
  61. alter(proj, "inc1");
  62. build(proj);
  63. checkWasntFullBuild();
  64. checkCompileWeaveCount(proj, 1, 1);
  65. long whitespacechangeDontTellCompiler = getTimeTakenForBuild(proj);
  66. System.out.println("Incr build time for whitespace change: " + whitespacechangeDontTellCompiler + "ms");
  67. // Similar to previous test, touch that file, but this time tell the compiler which file has changed. What should happen?
  68. // As we are telling the compiler what has changed, it will not jump through hoops checking the last mod time of
  69. // every source file in the project configuration.
  70. alter(proj, "inc1");
  71. addProjectSourceFileChanged(proj, getProjectRelativePath(proj, "src/out/C0.java"));
  72. build(proj);
  73. checkWasntFullBuild();
  74. checkCompileWeaveCount(proj, 1, 1);
  75. long whitespacechangeDoTellCompiler = getTimeTakenForBuild(proj);
  76. System.out.println("Incr build time for whitespace change (where we tell the compiler what changed): "
  77. + whitespacechangeDoTellCompiler + "ms");
  78. // Lets assert what really ought to be true
  79. assertTrue(nochangebuild < fullbuildtime);
  80. assertTrue(whitespacechangeDontTellCompiler < fullbuildtime);
  81. assertTrue(whitespacechangeDoTellCompiler < fullbuildtime);
  82. assertTrue(nochangebuild < whitespacechangeDontTellCompiler);
  83. // assertTrue(nochangebuild < whitespacechangeDoTellCompiler);
  84. // assertTrue(whitespacechangeDoTellCompiler < whitespacechangeDontTellCompiler);
  85. }
  86. /**
  87. * Project dependencies are captured by using classpath. The dependee project has the bin folder for the project upon which it
  88. * depends on its classpath. This can make it expensive when determining whether to build the dependee project as we may need to
  89. * analyse all the classpath entries, we don't know which are project related. However, a new API in ICompilerConfiguration
  90. * called getClasspathElementsWithModifiedContents() can be returned by an implementor to tell us which parts of the classpath
  91. * to check.
  92. */
  93. public void testBuildingTwoProjects() {
  94. AjdeInteractionTestbed.VERBOSE = true;
  95. String projA = "Proj64";
  96. String projB = "Dependee";
  97. // A full build:
  98. initialiseProject(projA);
  99. initialiseProject(projB);
  100. configureNewProjectDependency(projB, projA);
  101. build(projA);
  102. checkWasFullBuild();
  103. build(projB);
  104. checkWasFullBuild();
  105. alter(projA, "C43changeOne"); // C43 made package private
  106. build(projA);
  107. setNextChangeResponse(projB, ICompilerConfiguration.EVERYTHING);
  108. build(projB);
  109. long timeTakenWhenFullyAnalysingClasspath = getTimeTakenForBuild(projB);
  110. checkWasntFullBuild();
  111. alter(projA, "C43changeOne"); // C43 made package private
  112. build(projA);
  113. addClasspathEntryChanged(projB, getProjectRelativePath(projA, "bin").getPath());
  114. // waitForReturn();
  115. build(projB);
  116. long timeTakenWhenFullyToldSpecifically = getTimeTakenForBuild(projB);
  117. // waitFor10();
  118. checkWasntFullBuild();
  119. System.out.println("Without: " + timeTakenWhenFullyAnalysingClasspath + "ms With: " + timeTakenWhenFullyToldSpecifically
  120. + "ms");
  121. }
  122. // --- helper code ---
  123. @SuppressWarnings("unused")
  124. private void waitFor10() {
  125. try {
  126. Thread.sleep(10000);
  127. } catch (Exception e) {
  128. e.printStackTrace();
  129. }
  130. }
  131. @SuppressWarnings("unused")
  132. private void waitForReturn() {
  133. try {
  134. System.in.read();
  135. } catch (IOException e) {
  136. e.printStackTrace();
  137. }
  138. }
  139. @Override
  140. protected void setUp() throws Exception {
  141. super.setUp();
  142. testdataSrcDir = "../tests/incrementalPerformance";
  143. }
  144. @Override
  145. protected void tearDown() throws Exception {
  146. super.tearDown();
  147. testdataSrcDir = "../tests/multiIncremental";
  148. }
  149. }