// $Id: ProceedMeasurements2_rejitOverhead4_aj.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.inf.util.junit.PerformanceTest;
import ch.ethz.inf.util.junit.PerformanceTestSuite;
//import ch.ethz.prose.jikesrvm.JikesRVMPerformanceTest;
import java.lang.reflect.Method;
/**
* 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_aj extends PerformanceTest {
//public class ProceedMeasurements2_rejitOverhead4_aj extends JikesRVMPerformanceTest {
public boolean checkAssert = true;
public static int counter = 0;
//public int field = 0;
//public Method method;
/* // This method has been moved in a separate class
public int localMethod (int k) {
field = k;
//System.err.println("localMethod() - field = " + field);
return field;
}
*/
/*BEFORE:
public void localMethod() {
field = 1;
//System.err.println("localMethod() - field = " + field);
}
*/
/**
* Construct test with given name.
* @param name test name
*/
public ProceedMeasurements2_rejitOverhead4_aj(String name) {
super(name);
RANGE = new int[] { 1, 1 };
//RANGE = new int[] { 100000 };
}
/**
* Set up fixture.
*/
protected void setUp() {
counter = 0;
//field = 0;
}
protected void tearDown() { }
//========= INVOKEVIRTUAL =========
// load class + Load-time weaving overhead + method execution
public void testVirtualMethodRedefinition_int() {
// System.err.println(">>>>>>>>>>>> Sleep 5 seconds! <<<<<<<<<<<<<<");
// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
TestClass_rejitOverhead4_aj ob = new TestClass_rejitOverhead4_aj();
startChronometer();
ob.localMethod(10);
stopChronometer();
// System.err.println(">>>>>>>>>>>> Sleep 5 seconds! <<<<<<<<<<<<<<");
// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
// startChronometer();
// TestClass_rejitOverhead4_aj2 ob2 = new TestClass_rejitOverhead4_aj2();
// ob2.calllocalMethod(10);
// stopChronometer();
// System.err.println(">>>>>>>>>>>> AFTER STOP Sleep 5 seconds! <<<<<<<<<<<<<<");
// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
if(checkAssert) assertEquals("Hook notifications", 1, counter);
}
/*
//========= INVOKEVIRTUAL with Reflection =========
// load-time weaving overhead / cost
public void testVirtualMethodRedefinition_int() {
Class toload;
Object obj;
/// System.err.println(">>>>>>>>>>>> Sleep 5 seconds! <<<<<<<<<<<<<<");
/// try { Thread.currentThread().sleep(5000); } catch(InterruptedException e) { }
startChronometer();
toload = TestClass_rejitOverhead4_aj.class;
try {
//toload = Class.forName("measurements.suites.TestAngy");
method = toload.getDeclaredMethod("localMethod", new Class[] {Integer.TYPE} );
obj = toload.newInstance();
method.invoke(obj, new Object[]{new Integer(20)});
} catch(Throwable ex) {
System.err.println("The class has not been found => " + ex);
}
stopChronometer();
}
*/
/**
* Test suite.
* @return test instance
*/
public static Test suite() {
return new PerformanceTestSuite(ProceedMeasurements2_rejitOverhead4_aj.class);
}
}