// $Id: BenchmarkMeasurement.java,v 1.3 2008/11/18 10:41:01 anicoara Exp $
// =====================================================================
package measurements.suites;
// used packages
import junit.framework.Test;
import ch.ethz.inf.util.junit.PerformanceTest;
import ch.ethz.inf.util.junit.PerformanceTestSuite;
import ch.ethz.prose.Aspect;
import ch.ethz.prose.ProseSystem;
/**
* Performance testcase for measuring XXX.
* <p>
* In this testcase,the column <code>RUNS</code> (the fifths)
* represents XXX
*
* @version $Revision: 1.3 $
* @author Andrei Popovici
*/
public class BenchmarkMeasurement extends PerformanceTest {
// fixture
{ RANGE = new int[]{1000000};}
TestClass measurementObject;
TestClass calibrationObject;
boolean useProse = true;
boolean callDummyMethod = false;
void dummyMethod(boolean callRecursively) {
if (callRecursively)
dummyMethod(callRecursively);
}
/**
* Construct test with given name.
* @param name test name
*/
public BenchmarkMeasurement(String name) {
super(name);
}
/**
* Set up fixture.
*/
protected void setUp() throws Exception {
String proseParam = System.getProperty("useprose",
"" + isDebuggerEnabled());
useProse = proseParam.toUpperCase().equals("TRUE");
if (isDebuggerEnabled())
RANGE=new int[]{10000};
measurementObject = new TestClass1();
calibrationObject = new TestClassCalibration1();
String aspectToInsert = System.getProperty("aspect");
if (aspectToInsert == null) {
return;
}
if (useProse) {
Aspect x = null;
ProseSystem.startup();
if ("EfficientExtension".equals(aspectToInsert))
x = new EfficientExtension();
else if ("EfficientEntryExtension".equals(aspectToInsert))
x = new EfficientEntryExtension();
else if ("EfficientExitExtension".equals(aspectToInsert))
x = new EfficientExitExtension();
else
x = null;
if (x!= null)
ProseSystem.getAspectManager().insert(x);
}
else {
//angy ATENTIE!!!
if ("EfficientAspect".equals(aspectToInsert)) {
measurementObject = new TestClass2();
calibrationObject = new TestClassCalibration2();
}
else if ("EfficientEntryAspect".equals(aspectToInsert)) {
measurementObject = new TestClass3();
calibrationObject = new TestClassCalibration3();
}
else if ("EfficientExitAspect".equals(aspectToInsert)) {
measurementObject = new TestClass4();
calibrationObject = new TestClassCalibration4();
}
else
throw new RuntimeException("BenchmarkMeasurement.setUp:Illegal value for 'aspect'");
}
}
/** Turn off stuff
*/
protected void tearDown() throws Exception {
if (useProse)
ProseSystem.teardown();
}
public void test10FieldAdvice() {
startChronometer();
for (int i=0; i< RUNS; i++) {
measurementObject.testFieldOperations();
}
}
public void test10FieldCalibration() {
startChronometer();
for (int i=0; i< RUNS; i++) {
calibrationObject.testFieldOperations();
}
}
public void test11MethodAdvice() {
RUNS=100000;
startChronometer();
for (int i=0; i< RUNS; i++) {
measurementObject.testMethodOperations();
}
}
public void test11MethodCalibration() {
startChronometer();
for (int i=0; i< RUNS; i++) {
calibrationObject.testMethodOperations();
}
}
public void test12NoAdvice() {
startChronometer();
for (int i=0; i< RUNS; i++) {
measurementObject.testNonJPOperations();
}
}
public void test12NoAdviceCalibration() {
startChronometer();
for (int i=0; i< RUNS; i++) {
calibrationObject.testNonJPOperations();
}
}
public void test00CalibrationCall() {
startChronometer();
for(int i = 0; i < RUNS; i++) {
if (callDummyMethod) {
dummyMethod(callDummyMethod);
}
}
}
public void test01InterfaceCallShort() {
TestInterface interfaceObject = measurementObject;
startChronometer();
for (int i=0; i < RUNS; i++) {
interfaceObject.interfaceMethodShort();
}
}
public void test01InterfaceCallLong() {
String x = "hello";
TestInterface interfaceObject = measurementObject;
startChronometer();
for (int i=0; i < RUNS; i++) {
interfaceObject.interfaceMethodLong(x,x);
}
}
public void test02VirtualCallShort() {
startChronometer();
for (int i=0; i < RUNS; i++) {
measurementObject.instanceMethodShort();
}
}
public void test02VirtualCallLong() {
String x = "String";
startChronometer();
for (int i=0; i < RUNS; i++) {
measurementObject.instanceMethodLong(x,x);
}
}
public void test03SyncVirtualCallShort() {
startChronometer();
for (int i=0; i < RUNS; i++) {
measurementObject.syncInstanceMethodShort();
}
}
public void test03SyncVirtualCallLong() {
String x = "String";
startChronometer();
for (int i=0; i < RUNS; i++) {
measurementObject.syncInstanceMethodLong(x,x);
}
}
public void test04PutField() {
startChronometer();
measurementObject.testPutField(RUNS);
}
public void test04PutFieldCalibration() {
startChronometer();
calibrationObject.testPutField(RUNS);
}
public void test05GetField() {
startChronometer();
measurementObject.testGetField(RUNS);
}
public void test05GetFieldCalibration() {
startChronometer();
calibrationObject.testGetField(RUNS);
}
/**
* Test suite.
* @return test instance
*/
public static Test suite() {
return new PerformanceTestSuite(BenchmarkMeasurement.class);
}
}