001: // $Id: BenchmarkMeasurement.java,v 1.2 2004/05/12 17:26:52 anicoara Exp $
002: // =====================================================================
003: //
004: // (history at end)
005: //
006:
007: package measurements.suites;
008:
009: // used packages
010: import junit.framework.Test;
011: import ch.ethz.inf.util.junit.PerformanceTest;
012: import ch.ethz.inf.util.junit.PerformanceTestSuite;
013: import ch.ethz.prose.Aspect;
014: import ch.ethz.prose.ProseSystem;
015:
016: /**
017: * Performance testcase for measuring XXX.
018: * <p>
019: * In this testcase,the column <code>RUNS</code> (the fifths)
020: * represents XXX
021: *
022: * @version $Revision: 1.2 $
023: * @author Andrei Popovici
024: */
025: public class BenchmarkMeasurement extends PerformanceTest {
026:
027: // fixture
028: {
029: RANGE = new int[] { 1000000 };
030: }
031: TestClass measurementObject;
032: TestClass calibrationObject;
033: boolean useProse = true;
034:
035: boolean callDummyMethod = false;
036:
037: void dummyMethod(boolean callRecursively) {
038: if (callRecursively)
039: dummyMethod(callRecursively);
040: }
041:
042: /**
043: * Construct test with given name.
044: * @param name test name
045: */
046: public BenchmarkMeasurement(String name) {
047: super (name);
048: }
049:
050: /**
051: * Set up fixture.
052: */
053: protected void setUp() throws Exception {
054: String proseParam = System.getProperty("useprose", ""
055: + isDebuggerEnabled());
056: useProse = proseParam.toUpperCase().equals("TRUE");
057:
058: if (isDebuggerEnabled())
059: RANGE = new int[] { 10000 };
060: measurementObject = new TestClass1();
061: calibrationObject = new TestClassCalibration1();
062: String aspectToInsert = System.getProperty("aspect");
063: if (aspectToInsert == null) {
064: return;
065: }
066:
067: if (useProse) {
068: Aspect x = null;
069: ProseSystem.startup();
070:
071: if ("EfficientExtension".equals(aspectToInsert))
072: x = new EfficientExtension();
073: else if ("EfficientEntryExtension".equals(aspectToInsert))
074: x = new EfficientEntryExtension();
075: else if ("EfficientExitExtension".equals(aspectToInsert))
076: x = new EfficientExitExtension();
077: else
078: x = null;
079:
080: if (x != null)
081: ProseSystem.getAspectManager().insert(x);
082: } else {
083:
084: //angy ATENTIE!!!
085: if ("EfficientAspect".equals(aspectToInsert)) {
086: measurementObject = new TestClass2();
087:
088: calibrationObject = new TestClassCalibration2();
089:
090: } else if ("EfficientEntryAspect".equals(aspectToInsert)) {
091: measurementObject = new TestClass3();
092:
093: calibrationObject = new TestClassCalibration3();
094: } else if ("EfficientExitAspect".equals(aspectToInsert)) {
095: measurementObject = new TestClass4();
096:
097: calibrationObject = new TestClassCalibration4();
098: } else
099: throw new RuntimeException(
100: "BenchmarkMeasurement.setUp:Illegal value for 'aspect'");
101:
102: }
103: }
104:
105: /** Turn off stuff
106: */
107: protected void tearDown() throws Exception {
108: if (useProse)
109: ProseSystem.teardown();
110: }
111:
112: public void test10FieldAdvice() {
113: startChronometer();
114: for (int i = 0; i < RUNS; i++) {
115: measurementObject.testFieldOperations();
116: }
117: }
118:
119: public void test10FieldCalibration() {
120: startChronometer();
121: for (int i = 0; i < RUNS; i++) {
122: calibrationObject.testFieldOperations();
123: }
124: }
125:
126: public void test11MethodAdvice() {
127: RUNS = 100000;
128: startChronometer();
129: for (int i = 0; i < RUNS; i++) {
130: measurementObject.testMethodOperations();
131: }
132: }
133:
134: public void test11MethodCalibration() {
135: startChronometer();
136: for (int i = 0; i < RUNS; i++) {
137: calibrationObject.testMethodOperations();
138: }
139: }
140:
141: public void test12NoAdvice() {
142: startChronometer();
143: for (int i = 0; i < RUNS; i++) {
144: measurementObject.testNonJPOperations();
145: }
146: }
147:
148: public void test12NoAdviceCalibration() {
149: startChronometer();
150: for (int i = 0; i < RUNS; i++) {
151: calibrationObject.testNonJPOperations();
152: }
153: }
154:
155: public void test00CalibrationCall() {
156: startChronometer();
157: for (int i = 0; i < RUNS; i++) {
158: if (callDummyMethod) {
159: dummyMethod(callDummyMethod);
160: }
161: }
162: }
163:
164: public void test01InterfaceCallShort() {
165:
166: TestInterface interfaceObject = measurementObject;
167: startChronometer();
168: for (int i = 0; i < RUNS; i++) {
169: interfaceObject.interfaceMethodShort();
170: }
171: }
172:
173: public void test01InterfaceCallLong() {
174: String x = "hello";
175: TestInterface interfaceObject = measurementObject;
176: startChronometer();
177: for (int i = 0; i < RUNS; i++) {
178: interfaceObject.interfaceMethodLong(x, x);
179: }
180: }
181:
182: public void test02VirtualCallShort() {
183: startChronometer();
184: for (int i = 0; i < RUNS; i++) {
185: measurementObject.instanceMethodShort();
186: }
187: }
188:
189: public void test02VirtualCallLong() {
190: String x = "String";
191: startChronometer();
192: for (int i = 0; i < RUNS; i++) {
193: measurementObject.instanceMethodLong(x, x);
194: }
195: }
196:
197: public void test03SyncVirtualCallShort() {
198: startChronometer();
199: for (int i = 0; i < RUNS; i++) {
200: measurementObject.syncInstanceMethodShort();
201: }
202: }
203:
204: public void test03SyncVirtualCallLong() {
205: String x = "String";
206: startChronometer();
207: for (int i = 0; i < RUNS; i++) {
208: measurementObject.syncInstanceMethodLong(x, x);
209: }
210: }
211:
212: public void test04PutField() {
213: startChronometer();
214:
215: measurementObject.testPutField(RUNS);
216: }
217:
218: public void test04PutFieldCalibration() {
219: startChronometer();
220: calibrationObject.testPutField(RUNS);
221: }
222:
223: public void test05GetField() {
224: startChronometer();
225: measurementObject.testGetField(RUNS);
226: }
227:
228: public void test05GetFieldCalibration() {
229: startChronometer();
230: calibrationObject.testGetField(RUNS);
231: }
232:
233: /**
234: * Test suite.
235: * @return test instance
236: */
237: public static Test suite() {
238: return new PerformanceTestSuite(BenchmarkMeasurement.class);
239: }
240:
241: }
242:
243: //======================================================================
244: //
245: // $Log: BenchmarkMeasurement.java,v $
246: // Revision 1.2 2004/05/12 17:26:52 anicoara
247: // Adapt Junit tests to 3.8.1 version and the new package structure
248: //
249: // Revision 1.1.1.1 2003/07/02 15:30:45 apopovic
250: // Imported from ETH Zurich
251: //
252: // Revision 1.13 2003/07/02 12:42:39 anicoara
253: // Added CatchJoinPoint Functionality (Requests, Join-Points, Filters, CatchCuts, Tests)
254: //
255: // Revision 1.12 2003/05/05 14:03:03 popovici
256: // renaming from runes to prose
257: //
258: // Revision 1.11 2003/04/17 15:14:53 popovici
259: // Extension->Aspect renaming
260: //
261: // Revision 1.10 2003/03/04 18:35:58 popovici
262: // Organization of imprts
263: //
264: // Revision 1.9 2003/03/04 11:26:09 popovici
265: // Important refactorization step (march):
266: // - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
267: // - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
268: // structures
269: //
270: // Revision 1.8 2002/11/26 17:15:49 pschoch
271: // RootComponent now added (replaces RootComponent now added (replaces old ProseSystem)
272: // ProseSystem now owns and starts the Aspect interface.
273: // ProseSystem now containes a 'test' AspectManager
274: // AspectManager now owns the JoinPointManager.
275: // ExtensionManger can be 'connected' to the JVM, or disconnected. The
276: // JoinPointManager of a connected Ext.Mgr enables joinpoints; the
277: // JoinPointManger of a disconnected Ext.Mgr never enables join-points
278: // Documentation updated accordingly.
279: //
280: // Revision 1.7 2002/09/27 14:19:58 popovici
281: // Added unified nr of iterations depending on enabled debugger
282: //
283: // Revision 1.6 2002/05/06 09:08:11 popovici
284: // all _test now real test cases; JVMAI measurement enhanced with interface testing
285: //
286: // Revision 1.5 2002/03/28 09:15:35 popovici
287: // CrosscutMeasurement not any more in All Measurements
288: //
289: // Revision 1.4 2002/03/18 12:47:25 popovici
290: // *** empty log message ***
291: //
292: // Revision 1.3 2002/03/14 08:46:22 popovici
293: // Minor adaptations and corrections
294: //
295: // Revision 1.2 2002/03/12 10:17:19 popovici
296: // Long methods now (Object,Object); syntax corrections
297: //
298: // Revision 1.1 2002/03/12 09:50:13 popovici
299: // Initial version of the Benchmark measurements
300: //
|