You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ModelPerformanceTest.java 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* *******************************************************************
  2. * Copyright (c) 2003 Contributors.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-v10.html
  8. *
  9. * Contributors:
  10. * Mik Kersten initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.ajde;
  13. /**
  14. * @author Mik Kersten
  15. */
  16. public class ModelPerformanceTest extends AjdeTestCase {
  17. private final String CONFIG_FILE_PATH = "../examples/spacewar/spacewar/debug.lst";
  18. public ModelPerformanceTest(String name) {
  19. super(name);
  20. }
  21. public static void main(String[] args) {
  22. junit.swingui.TestRunner.run(ModelPerformanceTest.class);
  23. }
  24. /**
  25. * Assert that a compile that includes building the structure model
  26. * adds an acceptable percentage of overhead.
  27. *
  28. * Does a few initial builds to minimize caching effects.
  29. */
  30. public void testRelativeToNoModel() {
  31. timedBuild(true);
  32. timedBuild(false);
  33. timedBuild(true);
  34. long rawBuildTime = timedBuild(false);
  35. long modelBuildTime = timedBuild(true);
  36. float overhead = (float)modelBuildTime / (float)rawBuildTime;
  37. assertTrue("overhead is " + overhead + " > 1.3", overhead < 1.3);
  38. // System.err.println("> overhead: " + overhead);
  39. }
  40. public long timedBuild(boolean buildModel) {
  41. long startTime = System.currentTimeMillis();
  42. doSynchronousBuild(CONFIG_FILE_PATH);
  43. Ajde.getDefault().getBuildManager().setBuildModelMode(buildModel);
  44. long endTime = System.currentTimeMillis();
  45. return (endTime - startTime);
  46. }
  47. protected void setUp() throws Exception {
  48. super.setUp("examples");
  49. }
  50. protected void tearDown() throws Exception {
  51. super.tearDown();
  52. }
  53. }