// $Id: ProceedMeasurements2_rejitOverhead4.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_rejitOverhead4 extends PerformanceTest {
//public class ProceedMeasurements2_rejitOverhead4 extends JikesRVMPerformanceTest {
// public int field = 0;
public boolean checkAssert = true;
public static int counter = 0;
/*BEFORE:
public void localMethod() {
field = 1;
//System.err.println("localMethod() - field = " + field);
}
*/
/* //This method has been moved in a separate class
public int localMethod (int k) {
field = k;
//System.err.println("localMethod() - field = " + field);
return field;
}
*/
// METHOD REDEFINITION - no proceed()
public class MethodRedefineAspect1 extends DefaultAspect {
public Crosscut c1 = new MethodRedefineCut() {
// the new method code
//public int METHOD_ARGS(ProceedMeasurements2_rejitOverhead4 target, int k) {
public int METHOD_ARGS(TestClass_rejitOverhead4_aj target, int k) {
counter++;
return k;
}
protected PointCutter pointCutter() {
//return ( (Within.method("^localMethod$")) .AND (Within.type("^ProceedMeasurements2_rejitOverhead4$")) );
return ( (Within.method("^localMethod$")) .AND (Within.type("^TestClass_rejitOverhead4_aj$")) );
}
};
}
// METHOD REDEFINITION - one proceed()
public class MethodRedefineAspect2 extends DefaultAspect {
public Crosscut c2 = new MethodRedefineCut() {
// the new method code
//public int METHOD_ARGS(ProceedMeasurements2_rejitOverhead4 target, int k) {
public int METHOD_ARGS(TestClass_rejitOverhead4_aj target, int k) {
counter++;
proceed();
return k;
}
protected PointCutter pointCutter() {
//return ( (Within.method("^localMethod$")) .AND (Within.type("^ProceedMeasurements2_rejitOverhead4$")) );
return ( (Within.method("^localMethod$")) .AND (Within.type("^TestClass_rejitOverhead4_aj$")) );
}
};
}
// METHOD REDEFINITION - two proceed()
public class MethodRedefineAspect3 extends DefaultAspect {
public Crosscut c3 = new MethodRedefineCut() {
// the new method code
//public int METHOD_ARGS(ProceedMeasurements2_rejitOverhead4 target, int k) {
public int METHOD_ARGS(TestClass_rejitOverhead4_aj target, int k) {
counter++;
proceed();
proceed();
return k;
}
protected PointCutter pointCutter() {
//return ( (Within.method("^localMethod$")) .AND (Within.type("^ProceedMeasurements2_rejitOverhead4$")) );
return ( (Within.method("^localMethod$")) .AND (Within.type("^TestClass_rejitOverhead4_aj$")) );
}
};
}
// METHOD REDEFINITION - three proceed()
public class MethodRedefineAspect4 extends DefaultAspect {
public Crosscut c4 = new MethodRedefineCut() {
// the new method code
//public int METHOD_ARGS(ProceedMeasurements2_rejitOverhead4 target, int k) {
public int METHOD_ARGS(TestClass_rejitOverhead4_aj target, int k) {
counter++;
proceed();
proceed();
proceed();
return k;
}
protected PointCutter pointCutter() {
//return ( (Within.method("^localMethod$")) .AND (Within.type("^ProceedMeasurements2_rejitOverhead4$")) );
return ( (Within.method("^localMethod$")) .AND (Within.type("^TestClass_rejitOverhead4_aj$")) );
}
};
}
// METHOD REDEFINITION - four proceed()
public class MethodRedefineAspect5 extends DefaultAspect {
public Crosscut c5 = new MethodRedefineCut() {
// the new method code
//public int METHOD_ARGS(ProceedMeasurements2_rejitOverhead4 target, int k) {
public int METHOD_ARGS(TestClass_rejitOverhead4_aj target, int k) {
counter++;
proceed();
proceed();
proceed();
proceed();
return k;
}
protected PointCutter pointCutter() {
//return ( (Within.method("^localMethod$")) .AND (Within.type("^ProceedMeasurements2_rejitOverhead4$")) );
return ( (Within.method("^localMethod$")) .AND (Within.type("^TestClass_rejitOverhead4_aj$")) );
}
};
}
// METHOD REDEFINITION - five proceed()
public class MethodRedefineAspect6 extends DefaultAspect {
public Crosscut c6 = new MethodRedefineCut() {
// the new method code
//public int METHOD_ARGS(ProceedMeasurements2_rejitOverhead4 target, int k) {
public int METHOD_ARGS(TestClass_rejitOverhead4_aj target, int k) {
counter++;
proceed();
proceed();
proceed();
proceed();
proceed();
return k;
}
protected PointCutter pointCutter() {
//return ( (Within.method("^localMethod$")) .AND (Within.type("^ProceedMeasurements2_rejitOverhead4$")) );
return ( (Within.method("^localMethod$")) .AND (Within.type("^TestClass_rejitOverhead4_aj$")) );
}
};
}
Aspect aspect1; // METHOD REDEFINITION - no proceed()
Aspect aspect2; // METHOD REDEFINITION - one proceed()
Aspect aspect3; // METHOD REDEFINITION - two proceed()
Aspect aspect4; // METHOD REDEFINITION - three proceed()
Aspect aspect5; // METHOD REDEFINITION - four proceed()
Aspect aspect6; // METHOD REDEFINITION - five proceed()
public boolean useProse = false;
/**
* Construct test with given name.
* @param name test name
*/
public ProceedMeasurements2_rejitOverhead4(String name) {
super(name);
RANGE = new int[] { 1, 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");
}
aspect1 = new MethodRedefineAspect1();
aspect2 = new MethodRedefineAspect2();
aspect3 = new MethodRedefineAspect3();
aspect4 = new MethodRedefineAspect4();
aspect5 = new MethodRedefineAspect5();
aspect6 = new MethodRedefineAspect6();
// field = 0;
counter = 0;
}
protected void tearDown() {
if (!useProse) return;
try {
ProseSystem.teardown();
} catch (Exception e) {
Assert.fail("ProseSystem.teardown() failed");
}
}
/*
//========= METHOD REDEFINITION - no proceed() =========
// aspect insertion + RTW overhead + method execution
public void test_RTW_overhead_for_MethodRedefinition_noProceed() {
// WARM-UP
//int sum = 0;
//for (int i=0; i < 100000; i++) { localMethod(i); sum += field; }
///localMethod(1); sum += field;
TestClass_rejitOverhead4_aj obj = new TestClass_rejitOverhead4_aj();
// System.err.println(">>>>>>>>>>>>>>>>> SLEEP 5 seconds - BEFORE STARTch <<<<<<<<");
// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
startChronometer();
ProseSystem.getAspectManager().insert(aspect1); //if (useProse)...
obj.localMethod(10);
stopChronometer();
// System.err.println(">>>>>>>>>>>>>>>>> AFTER STOPch <<<<<<<< ");
// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
if(useProse) ProseSystem.getAspectManager().withdraw(aspect1);
if(checkAssert) assertEquals("Hook notifications", 1, counter);
}
*/
/*
//========= METHOD REDEFINITION - one proceed() =========
// aspect insertion + RTW overhead + method execution
public void test_RTW_overhead_for_MethodRedefinition_oneProceed() {
//int sum = 0;
//for (int i=0; i < 100000; i++) { localMethod(i); sum += field; }
///localMethod(1); sum += field;
TestClass_rejitOverhead4_aj obj = new TestClass_rejitOverhead4_aj();
// System.err.println(">>>>>>>>>>>>>>>>> SLEEP 5 seconds - BEFORE STARTch <<<<<<<<");
// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
startChronometer();
ProseSystem.getAspectManager().insert(aspect2); //if (useProse)...
obj.localMethod(10);
stopChronometer();
// System.err.println(">>>>>>>>>>>>>>>>> AFTER STOPch <<<<<<<< ");
// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
if(useProse) ProseSystem.getAspectManager().withdraw(aspect2);
if(checkAssert) assertEquals("Hook notifications", 1, counter);
}
*/
/*
//========= METHOD REDEFINITION - two proceed() =========
// aspect insertion + RTW overhead + method execution
public void test_RTW_overhead_for_MethodRedefinition_twoProceed() {
//int sum = 0;
//for (int i=0; i < 100000; i++) { localMethod(i); sum += field; }
///localMethod(1); sum += field;
TestClass_rejitOverhead4_aj obj = new TestClass_rejitOverhead4_aj();
// System.err.println(">>>>>>>>>>>>>>>>> SLEEP 5 seconds - BEFORE STARTch <<<<<<<<");
// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
startChronometer();
ProseSystem.getAspectManager().insert(aspect3); //if (useProse)...
obj.localMethod(10);
stopChronometer();
// System.err.println(">>>>>>>>>>>>>>>>> AFTER STOPch <<<<<<<< ");
// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
if(useProse) ProseSystem.getAspectManager().withdraw(aspect3);
if(checkAssert) assertEquals("Hook notifications", 1, counter);
}
*/
/*
//========= METHOD REDEFINITION - three proceed() =========
// aspect insertion + RTW overhead + method execution
public void test_RTW_overhead_for_MethodRedefinition_threeProceed() {
//int sum = 0;
//for (int i=0; i < 100000; i++) { localMethod(i); sum += field; }
///localMethod(1); sum += field;
TestClass_rejitOverhead4_aj obj = new TestClass_rejitOverhead4_aj();
// System.err.println(">>>>>>>>>>>>>>>>> SLEEP 5 seconds - BEFORE STARTch <<<<<<<<");
// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
startChronometer();
ProseSystem.getAspectManager().insert(aspect4); //if (useProse)...
obj.localMethod(10);
stopChronometer();
// System.err.println(">>>>>>>>>>>>>>>>> AFTER STOPch <<<<<<<< ");
// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
if (useProse) ProseSystem.getAspectManager().withdraw(aspect4);
if(checkAssert) assertEquals("Hook notifications", 1, counter);
}
*/
/*
//========= METHOD REDEFINITION - four proceed() =========
// aspect insertion + RTW overhead + method execution
public void test_RTW_overhead_for_MethodRedefinition_fourProceed() {
//int sum = 0;
//for (int i=0; i < 100000; i++) { localMethod(i); sum += field; }
///localMethod(1); sum += field;
TestClass_rejitOverhead4_aj obj = new TestClass_rejitOverhead4_aj();
// System.err.println(">>>>>>>>>>>>>>>>> SLEEP 5 seconds - BEFORE STARTch <<<<<<<<");
// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
startChronometer();
ProseSystem.getAspectManager().insert(aspect5); //if (useProse)...
obj.localMethod(10);
stopChronometer();
// System.err.println(">>>>>>>>>>>>>>>>> AFTER STOPch <<<<<<<< ");
// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
if (useProse) ProseSystem.getAspectManager().withdraw(aspect5);
if(checkAssert) assertEquals("Hook notifications", 1, counter);
}
*/
//========= METHOD REDEFINITION - five proceed() =========
// aspect insertion + RTW overhead + method execution
public void test_RTW_overhead_for_MethodRedefinition_fiveProceed() {
//int sum = 0;
//for (int i=0; i < 100000; i++) { localMethod(i); sum += field; }
///localMethod(1); sum += field;
TestClass_rejitOverhead4_aj obj = new TestClass_rejitOverhead4_aj();
// System.err.println(">>>>>>>>>>>>>>>>> SLEEP 5 seconds - BEFORE STARTch <<<<<<<<");
// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
startChronometer();
ProseSystem.getAspectManager().insert(aspect6); //if (useProse)...
obj.localMethod(10);
stopChronometer();
// System.err.println(">>>>>>>>>>>>>>>>> AFTER STOPch <<<<<<<< ");
// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
if (useProse) ProseSystem.getAspectManager().withdraw(aspect6);
if(checkAssert) assertEquals("Hook notifications", 1, counter);
}
/**
* Test suite.
* @return test instance
*/
public static Test suite() {
return new PerformanceTestSuite(ProceedMeasurements2_rejitOverhead4.class);
}
}