Source code: measurements/suites/BenchmarkMeasurement.java
1 // $Id: BenchmarkMeasurement.java,v 1.1.1.1 2003/07/02 15:30:45 apopovic Exp $
2 // =====================================================================
3 //
4 // (history at end)
5 //
6
7 package measurements.suites;
8
9 // used packages
10 import junit.framework.Test;
11 import ch.ethz.prose.Aspect;
12 import ch.ethz.prose.ProseSystem;
13 import ch.ethz.inf.util.junit.PerformanceTest;
14 import ch.ethz.inf.util.junit.PerformanceTestSuite;
15
16
17 /**
18 * Performance testcase for measuring XXX.
19 * <p>
20 * In this testcase,the column <code>RUNS</code> (the fifths)
21 * represents XXX
22 *
23 * @version $Revision: 1.1.1.1 $
24 * @author Andrei Popovici
25 */
26 public
27 class BenchmarkMeasurement extends PerformanceTest {
28
29 // fixture
30 { RANGE = new int[]{1000000};}
31 TestClass measurementObject;
32 TestClass calibrationObject;
33 boolean useProse = true;
34
35
36 boolean callDummyMethod = false;
37 void dummyMethod(boolean callRecursively)
38 {
39 if (callRecursively)
40 dummyMethod(callRecursively);
41 }
42
43 /**
44 * Construct test with given name.
45 * @param name test name
46 */
47 public BenchmarkMeasurement(String name)
48 {
49 super(name);
50 }
51
52 /**
53 * Set up fixture.
54 */
55 protected
56 void setUp() throws Exception
57 {
58 String proseParam = System.getProperty("useprose",
59 "" + isDebuggerEnabled());
60 useProse = proseParam.toUpperCase().equals("TRUE");
61
62 if (isDebuggerEnabled())
63 RANGE=new int[]{10000};
64 measurementObject = new TestClass1();
65 calibrationObject = new TestClassCalibration1();
66 String aspectToInsert = System.getProperty("aspect");
67 if (aspectToInsert == null)
68 {
69 return;
70 }
71
72 if (useProse)
73 {
74 Aspect x = null;
75 ProseSystem.startup();
76
77 if ("EfficientExtension".equals(aspectToInsert))
78 x = new EfficientExtension();
79 else if ("EfficientEntryExtension".equals(aspectToInsert))
80 x = new EfficientEntryExtension();
81 else if ("EfficientExitExtension".equals(aspectToInsert))
82 x = new EfficientExitExtension();
83 else
84 x = null;
85
86 if (x!= null)
87 ProseSystem.getAspectManager().insert(x);
88 }
89 else
90 {
91
92 //angy ATENTIE!!!
93 if ("EfficientAspect".equals(aspectToInsert))
94 {
95 measurementObject = new TestClass2();
96
97 calibrationObject = new TestClassCalibration2();
98
99 }
100 else if ("EfficientEntryAspect".equals(aspectToInsert))
101 {
102 measurementObject = new TestClass3();
103
104 calibrationObject = new TestClassCalibration3();
105 }
106 else if ("EfficientExitAspect".equals(aspectToInsert))
107 {
108 measurementObject = new TestClass4();
109
110 calibrationObject = new TestClassCalibration4();
111 }
112 else
113 throw new RuntimeException("BenchmarkMeasurement.setUp:Illegal value for 'aspect'");
114
115 }
116 }
117
118 /** Turn off stuff
119 */
120 protected void tearDown() throws Exception
121 {
122 if (useProse)
123 ProseSystem.teardown();
124 }
125
126 public void test10FieldAdvice()
127 {
128 startChronometer();
129 for (int i=0; i< RUNS; i++)
130 {
131 measurementObject.testFieldOperations();
132 }
133 }
134
135 public void test10FieldCalibration()
136 {
137 startChronometer();
138 for (int i=0; i< RUNS; i++)
139 {
140 calibrationObject.testFieldOperations();
141 }
142 }
143
144 public void test11MethodAdvice()
145 {
146 RUNS=100000;
147 startChronometer();
148 for (int i=0; i< RUNS; i++)
149 {
150 measurementObject.testMethodOperations();
151 }
152 }
153
154 public void test11MethodCalibration()
155 {
156 startChronometer();
157 for (int i=0; i< RUNS; i++)
158 {
159 calibrationObject.testMethodOperations();
160 }
161 }
162
163 public void test12NoAdvice()
164 {
165 startChronometer();
166 for (int i=0; i< RUNS; i++)
167 {
168 measurementObject.testNonJPOperations();
169 }
170 }
171
172 public void test12NoAdviceCalibration()
173 {
174 startChronometer();
175 for (int i=0; i< RUNS; i++)
176 {
177 calibrationObject.testNonJPOperations();
178 }
179 }
180
181 public void test00CalibrationCall()
182 {
183 startChronometer();
184 for(int i = 0; i < RUNS; i++)
185 {
186 if (callDummyMethod)
187 { dummyMethod(callDummyMethod); }
188 }
189 }
190
191 public void test01InterfaceCallShort()
192 {
193
194 TestInterface interfaceObject = measurementObject;
195 startChronometer();
196 for (int i=0; i < RUNS; i++)
197 {
198 interfaceObject.interfaceMethodShort();
199 }
200 }
201
202 public void test01InterfaceCallLong()
203 {
204 String x = "hello";
205 TestInterface interfaceObject = measurementObject;
206 startChronometer();
207 for (int i=0; i < RUNS; i++)
208 {
209 interfaceObject.interfaceMethodLong(x,x);
210 }
211 }
212
213
214
215 public void test02VirtualCallShort()
216 {
217 startChronometer();
218 for (int i=0; i < RUNS; i++)
219 {
220 measurementObject.instanceMethodShort();
221 }
222 }
223
224 public void test02VirtualCallLong()
225 {
226 String x = "String";
227 startChronometer();
228 for (int i=0; i < RUNS; i++)
229 {
230 measurementObject.instanceMethodLong(x,x);
231 }
232 }
233
234
235
236 public void test03SyncVirtualCallShort()
237 {
238 startChronometer();
239 for (int i=0; i < RUNS; i++)
240 {
241 measurementObject.syncInstanceMethodShort();
242 }
243 }
244
245 public void test03SyncVirtualCallLong()
246 {
247 String x = "String";
248 startChronometer();
249 for (int i=0; i < RUNS; i++)
250 {
251 measurementObject.syncInstanceMethodLong(x,x);
252 }
253 }
254
255 public void test04PutField()
256 {
257 startChronometer();
258
259 measurementObject.testPutField(RUNS);
260 }
261
262 public void test04PutFieldCalibration()
263 {
264 startChronometer();
265 calibrationObject.testPutField(RUNS);
266 }
267
268 public void test05GetField()
269 {startChronometer();
270 measurementObject.testGetField(RUNS);
271 }
272
273 public void test05GetFieldCalibration()
274 {startChronometer();
275 calibrationObject.testGetField(RUNS);
276 }
277
278
279
280 /**
281 * Test suite.
282 * @return test instance
283 */
284 public static
285 Test suite()
286 {
287 return new PerformanceTestSuite(BenchmarkMeasurement.class);
288 }
289
290 }
291
292
293 //======================================================================
294 //
295 // $Log: BenchmarkMeasurement.java,v $
296 // Revision 1.1.1.1 2003/07/02 15:30:45 apopovic
297 // Imported from ETH Zurich
298 //
299 // Revision 1.13 2003/07/02 12:42:39 anicoara
300 // Added CatchJoinPoint Functionality (Requests, Join-Points, Filters, CatchCuts, Tests)
301 //
302 // Revision 1.12 2003/05/05 14:03:03 popovici
303 // renaming from runes to prose
304 //
305 // Revision 1.11 2003/04/17 15:14:53 popovici
306 // Extension->Aspect renaming
307 //
308 // Revision 1.10 2003/03/04 18:35:58 popovici
309 // Organization of imprts
310 //
311 // Revision 1.9 2003/03/04 11:26:09 popovici
312 // Important refactorization step (march):
313 // - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
314 // - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
315 // structures
316 //
317 // Revision 1.8 2002/11/26 17:15:49 pschoch
318 // RootComponent now added (replaces RootComponent now added (replaces old ProseSystem)
319 // ProseSystem now owns and starts the Aspect interface.
320 // ProseSystem now containes a 'test' AspectManager
321 // AspectManager now owns the JoinPointManager.
322 // ExtensionManger can be 'connected' to the JVM, or disconnected. The
323 // JoinPointManager of a connected Ext.Mgr enables joinpoints; the
324 // JoinPointManger of a disconnected Ext.Mgr never enables join-points
325 // Documentation updated accordingly.
326 //
327 // Revision 1.7 2002/09/27 14:19:58 popovici
328 // Added unified nr of iterations depending on enabled debugger
329 //
330 // Revision 1.6 2002/05/06 09:08:11 popovici
331 // all _test now real test cases; JVMAI measurement enhanced with interface testing
332 //
333 // Revision 1.5 2002/03/28 09:15:35 popovici
334 // CrosscutMeasurement not any more in All Measurements
335 //
336 // Revision 1.4 2002/03/18 12:47:25 popovici
337 // *** empty log message ***
338 //
339 // Revision 1.3 2002/03/14 08:46:22 popovici
340 // Minor adaptations and corrections
341 //
342 // Revision 1.2 2002/03/12 10:17:19 popovici
343 // Long methods now (Object,Object); syntax corrections
344 //
345 // Revision 1.1 2002/03/12 09:50:13 popovici
346 // Initial version of the Benchmark measurements
347 //