Package measurements.suites

Source Code of measurements.suites.ProceedMeasurements2_rejitOverhead3$MethodRedefineAspect_two_1

// $Id: ProceedMeasurements2_rejitOverhead3.java,v 1.1 2008/11/18 10:43:24 anicoara Exp $
// =========================================================================

package measurements.suites;

import junit.framework.Assert;
import junit.framework.Test;
import ch.ethz.prose.DefaultAspect;
import ch.ethz.prose.Aspect;
import ch.ethz.prose.ProseSystem;
import ch.ethz.prose.crosscut.Crosscut;
import ch.ethz.prose.crosscut.MethodCut;
import ch.ethz.prose.crosscut.MethodRedefineCut;
import ch.ethz.prose.crosscut.GetCut;
import ch.ethz.prose.crosscut.SetCut;
import ch.ethz.prose.filter.Fields;
import ch.ethz.prose.filter.PointCutter;
import ch.ethz.prose.filter.Executions;
import ch.ethz.prose.filter.Within;
import ch.ethz.inf.util.junit.PerformanceTest;
import ch.ethz.inf.util.junit.PerformanceTestSuite;
//import ch.ethz.prose.jikesrvm.JikesRVMPerformanceTest;

/**
*  JoinPoint measurements
*
* Performance tests to calculate the relative rejit overhead
* after the aspect has been inserted.
*
* @version  $Revision: 1.1 $
* @author  Angela Nicoara
*/
public class ProceedMeasurements2_rejitOverhead3 extends PerformanceTest {
//public class ProceedMeasurements2_rejitOverhead3 extends JikesRVMPerformanceTest {

  //  public int x;
  public int field = 0;
  public boolean checkAssert = true;

  public int localMethod (int k) {
    field = k;
    //x = 1;    //set the "x" field
    //System.err.println("localMethod() - field = " + field);
    return field;
  }

  ////////// SIXTEEN ///////////

  // METHOD REDEFINITION - sixteen proceed()
  public class MethodRedefineAspect_sixteen extends DefaultAspect {

    public Crosscut c1 = new MethodRedefineCut() {
      // the new method code
      public int METHOD_ARGS(ProceedMeasurements2_rejitOverhead3 target, int k) {
        proceed();
        proceed();
        proceed();
        proceed();
        proceed();
        proceed();
        proceed();
        proceed();
        proceed();
        proceed();
        proceed();
        proceed();
        proceed();
        proceed();
        proceed();
        proceed();
        //target.field = 50;
        return k;
      }

      protected PointCutter pointCutter() {
        return ( (Within.method("^localMethod$")) .AND (Within.type("^ProceedMeasurements2_rejitOverhead3$")) );
      }
    };
  }

  ////////// FOUR ///////////

  // METHOD REDEFINITION - four proceed()
  public class MethodRedefineAspect_four_1 extends DefaultAspect {

    public Crosscut c2 = new MethodRedefineCut() {
      // the new method code
      public int METHOD_ARGS(ProceedMeasurements2_rejitOverhead3 target, int k) {
        proceed();
        proceed();
        proceed();
        proceed();
        //target.field = 50;
        return k;
      }

      protected PointCutter pointCutter() {
        return ( (Within.method("^localMethod$")) .AND (Within.type("^ProceedMeasurements2_rejitOverhead3$")) );
      }
    };
  }

  // METHOD REDEFINITION - four proceed()
  public class MethodRedefineAspect_four_2 extends DefaultAspect {

    public Crosscut c3 = new MethodRedefineCut() {
      // the new method code
      public int METHOD_ARGS(ProceedMeasurements2_rejitOverhead3 target, int k) {
        proceed();
        proceed();
        proceed();
        proceed();
        //target.field = 50;
        return k;

      }

      protected PointCutter pointCutter() {
        return ( (Within.method("^localMethod$")) .AND (Within.type("^ProceedMeasurements2_rejitOverhead3$")) );
      }
    };
  }

  ////////// TWO ///////////

  // METHOD REDEFINITION - two proceed()
  public class MethodRedefineAspect_two_1 extends DefaultAspect {

    public Crosscut c4 = new MethodRedefineCut() {
      // the new method code
      public int METHOD_ARGS(ProceedMeasurements2_rejitOverhead3 target, int k) {
        proceed();
        proceed();
        //target.field = 50;
        return k;
      }

      protected PointCutter pointCutter() {
        return ( (Within.method("^localMethod$")) .AND (Within.type("^ProceedMeasurements2_rejitOverhead3$")) );
      }
    };
  }

  // METHOD REDEFINITION - two proceed()
  public class MethodRedefineAspect_two_2 extends DefaultAspect {

    public Crosscut c5 = new MethodRedefineCut() {
      // the new method code
      public int METHOD_ARGS(ProceedMeasurements2_rejitOverhead3 target, int k) {
        proceed();
        proceed();
        //target.field = 50;
        return k;
      }

      protected PointCutter pointCutter() {
        return ( (Within.method("^localMethod$")) .AND (Within.type("^ProceedMeasurements2_rejitOverhead3$")) );
      }
    };
  }

  // METHOD REDEFINITION - two proceed()
  public class MethodRedefineAspect_two_3 extends DefaultAspect {

    public Crosscut c6 = new MethodRedefineCut() {
      // the new method code
      public int METHOD_ARGS(ProceedMeasurements2_rejitOverhead3 target, int k) {
        proceed();
        proceed();
        //target.field = 50;
        return k;
      }

      protected PointCutter pointCutter() {
        return ( (Within.method("^localMethod$")) .AND (Within.type("^ProceedMeasurements2_rejitOverhead3$")) );
      }
    };
  }

  // METHOD REDEFINITION - two proceed()
  public class MethodRedefineAspect_two_4 extends DefaultAspect {

    public Crosscut c7 = new MethodRedefineCut() {
      // the new method code
      public int METHOD_ARGS(ProceedMeasurements2_rejitOverhead3 target, int k) {
        proceed();
        proceed();
        //target.field = 50;
        return k;
      }

      protected PointCutter pointCutter() {
        return ( (Within.method("^localMethod$")) .AND (Within.type("^ProceedMeasurements2_rejitOverhead3$")) );
      }
    };
  }


  Aspect aspect_sixteen;  // METHOD REDEFINITION - sixteen proceed()
  Aspect aspect_four_1;    // METHOD REDEFINITION - four_1 proceed()
  Aspect aspect_four_2;   // METHOD REDEFINITION - four_2 proceed()
  Aspect aspect_two_1;    // METHOD REDEFINITION - two_1 proceed()
  Aspect aspect_two_2;    // METHOD REDEFINITION - two_2 proceed()
  Aspect aspect_two_3;    // METHOD REDEFINITION - two_3 proceed()
  Aspect aspect_two_4;    // METHOD REDEFINITION - two_4 proceed()

  public boolean useProse = false;

  /**
   * Construct test with given name.
   * @param name test name
   */
  public ProceedMeasurements2_rejitOverhead3(String name) {
    super(name);
    RANGE = new int[] { 1 };
    //RANGE = new int[] { 100000 };

    String proseParam = System.getProperty("useprose");
    if (proseParam != null) useProse = true;   
  }

  /**
   * Set up fixture.
   */
  protected void setUp() {
    if (!useProse) return;

    try {
      ProseSystem.startup();
    } catch (Exception e) { Assert.fail("ProseSystem.startup() failed"); }

    aspect_sixteen  = new MethodRedefineAspect_sixteen();   // METHOD REDEFINITION - sixteen proceed()
    aspect_four_1 = new MethodRedefineAspect_four_1();   // METHOD REDEFINITION - four_1 proceed()
    aspect_four_2 = new MethodRedefineAspect_four_2();   // METHOD REDEFINITION - four_2 proceed()
    aspect_two_1 = new MethodRedefineAspect_two_1();   // METHOD REDEFINITION - two_1 proceed()
    aspect_two_2 = new MethodRedefineAspect_two_2();   // METHOD REDEFINITION - two_2 proceed()
    aspect_two_3 = new MethodRedefineAspect_two_3();   // METHOD REDEFINITION - two_3 proceed()
    aspect_two_4 = new MethodRedefineAspect_two_4();   // METHOD REDEFINITION - two_4 proceed()

    field = 0;
  }

  protected void tearDown() {
    if (!useProse) return;

    try {
      ProseSystem.teardown();
    } catch (Exception e) {
      Assert.fail("ProseSystem.teardown() failed");
    }
  }


  //========= METHOD REDEFINITION - sixteen proceed() =========

  // rejit overhead
  public void test_the_rejit_overhead_for_MethodRedefinition_sixteenProceed() {
    int sum = 0;
    for (int i=0; i < 100000; i++) { localMethod(i); sum += field; }

    if (useProse) ProseSystem.getAspectManager().insert(aspect_sixteen);

    startChronometer();
    for (int i=0; i < RUNS; i++) localMethod(i);
    stopChronometer();

    if (useProse) ProseSystem.getAspectManager().withdraw(aspect_sixteen);

    //if(checkAssert) assertEquals("Hook notifications", 10, field);
  }

  //========= METHOD REDEFINITION - four proceed() =========

  // rejit overhead
  public void test_the_rejit_overhead_for_MethodRedefinition_fourProceed() {
    int sum = 0;
    for (int i=0; i < 100000; i++) { localMethod(i); sum += field; }

    if (useProse) ProseSystem.getAspectManager().insert(aspect_four_1);
    if (useProse) ProseSystem.getAspectManager().insert(aspect_four_2);

    startChronometer();
    for (int i=0; i < RUNS; i++) localMethod(i);
    stopChronometer();

    if (useProse) ProseSystem.getAspectManager().withdraw(aspect_four_2);
    if (useProse) ProseSystem.getAspectManager().withdraw(aspect_four_1);

    //if(checkAssert) assertEquals("Hook notifications", 10, field);
  }

  //========= METHOD REDEFINITION - two proceed() =========

  // rejit overhead
  public void test_the_rejit_overhead_for_MethodRedefinition_twoProceed() {
    int sum = 0;
    for (int i=0; i < 100000; i++) { localMethod(i); sum += field; }

    if (useProse) ProseSystem.getAspectManager().insert(aspect_two_1);
    if (useProse) ProseSystem.getAspectManager().insert(aspect_two_2);
    if (useProse) ProseSystem.getAspectManager().insert(aspect_two_3);
    if (useProse) ProseSystem.getAspectManager().insert(aspect_two_4);

    startChronometer();
    for (int i=0; i < RUNS; i++) localMethod(i);
    stopChronometer();

    if (useProse) ProseSystem.getAspectManager().withdraw(aspect_two_4);
    if (useProse) ProseSystem.getAspectManager().withdraw(aspect_two_3);
    if (useProse) ProseSystem.getAspectManager().withdraw(aspect_two_2);
    if (useProse) ProseSystem.getAspectManager().withdraw(aspect_two_1);

    //if(checkAssert) assertEquals("Hook notifications", 10, field);
  }


  /**
   * Test suite.
   * @return test instance
   */
  public static Test suite() {
    return new PerformanceTestSuite(ProceedMeasurements2_rejitOverhead3.class);
  }
}
TOP

Related Classes of measurements.suites.ProceedMeasurements2_rejitOverhead3$MethodRedefineAspect_two_1

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.