1 package measurements.suites; 2 3 import junit.framework.Assert; 4 import junit.framework.Test; 5 import ch.ethz.prose.DefaultAspect; 6 import ch.ethz.prose.Aspect; 7 import ch.ethz.prose.ProseSystem; 8 import ch.ethz.prose.crosscut.Crosscut; 9 import ch.ethz.prose.crosscut.MethodCut; 10 import ch.ethz.prose.crosscut.MethodRedefineCut; 11 import ch.ethz.prose.crosscut.GetCut; 12 import ch.ethz.prose.crosscut.SetCut; 13 import ch.ethz.prose.filter.Fields; 14 import ch.ethz.prose.filter.PointCutter; 15 import ch.ethz.prose.filter.Executions; 16 import ch.ethz.prose.filter.Within; 17 import ch.ethz.inf.util.junit.PerformanceTest; 18 import ch.ethz.inf.util.junit.PerformanceTestSuite; 19 21 22 31 public class JoinPointMeasurements2_rejitOverhead2 extends PerformanceTest { 32 34 public int x; 35 public int y = 10; 36 public int z; 37 public int field = 0; 38 public boolean checkAssert = true; 39 40 public void localMethod() 41 { 42 x = 1; } 45 46 public void otherMethod() 47 { 48 z = y; } 51 52 public class MethodEntryAspect extends DefaultAspect 54 { 55 public Crosscut c1 = new MethodCut() 56 { 57 public void METHOD_ARGS(JoinPointMeasurements2_rejitOverhead2 target) 59 { 60 target.field = 20; 63 } 64 65 protected PointCutter pointCutter() 67 { 68 return ( (Executions.before()) . AND 69 (Within.method("localMethod")) . AND 70 (Within.type("JoinPointMeasurements2_rejitOverhead2")) ); 71 } 72 }; 73 } 74 75 public class MethodExitAspect extends DefaultAspect 77 { 78 public Crosscut c2 = new MethodCut() 79 { 80 public void METHOD_ARGS(JoinPointMeasurements2_rejitOverhead2 target) 82 { 83 target.field = 30; 86 } 87 88 protected PointCutter pointCutter() 90 { 91 return ( (Executions.after()) . AND 92 (Within.method("localMethod")) . AND 93 (Within.type("JoinPointMeasurements2_rejitOverhead2")) ); 94 } 95 }; 96 } 97 98 public class MethodRedefineAspect extends DefaultAspect 100 { 101 public Crosscut c3 = new MethodRedefineCut() 102 { 103 public void METHOD_ARGS(JoinPointMeasurements2_rejitOverhead2 target) 105 { 106 target.field = 40; 109 } 110 111 protected PointCutter pointCutter() 112 { 113 return ( (Within.method("localMethod")) .AND 114 (Within.type("JoinPointMeasurements2_rejitOverhead2")) ); 115 } 116 }; 117 } 118 119 public class FieldAccessAspect extends DefaultAspect 121 { 122 public Crosscut c4 = new GetCut() 123 { 124 public void GET_ARGS(JoinPointMeasurements2_rejitOverhead2 target, int x) { 129 target.field = 50; 132 } 133 134 protected PointCutter pointCutter() 135 { 136 return ( (Fields.named("y.*")) .AND (Fields.declaredInClass("JoinPointMeasurements2_rejitOverhead2")) ); 137 } 138 }; 139 } 140 141 public class FieldModificationAspect extends DefaultAspect 143 { 144 public Crosscut c5 = new SetCut() 145 { 146 public void SET_ARGS(JoinPointMeasurements2_rejitOverhead2 target, int x) { 151 target.field = 60; 154 } 155 156 protected PointCutter pointCutter() 157 { 158 return ( Fields.named("x.*") .AND (Fields.declaredInClass("JoinPointMeasurements2_rejitOverhead2")) ); 159 } 160 }; 161 } 162 163 Aspect aspect1; Aspect aspect2; Aspect aspect3; Aspect aspect4; Aspect aspect5; 169 public boolean useProse = false; 170 171 175 public JoinPointMeasurements2_rejitOverhead2(String name) 176 { 177 super(name); 178 RANGE = new int[] { 100000 }; 180 181 String proseParam = System.getProperty("useprose"); 182 if (proseParam != null) useProse = true; 183 } 184 185 188 protected void setUp() 189 { 190 if (!useProse) return; 191 192 try { 193 ProseSystem.startup(); 194 } catch (Exception e) { 195 Assert.fail("ProseSystem.startup() failed"); 196 } 197 198 aspect1 = new MethodEntryAspect(); 199 aspect2 = new MethodExitAspect(); 200 aspect3 = new MethodRedefineAspect(); 201 aspect4 = new FieldAccessAspect(); 202 aspect5 = new FieldModificationAspect(); 203 204 field = 0; 205 } 206 207 protected void tearDown() 208 { 209 if (!useProse) return; 210 211 try { 212 ProseSystem.teardown(); 213 } catch (Exception e) { 214 Assert.fail("ProseSystem.teardown() failed"); 215 } 216 } 217 218 220 public void test_the_rejit_overhead_for_MethodEntry_1() 222 { 223 if (useProse) ProseSystem.getAspectManager().insert(aspect1); 224 225 startChronometer(); 226 for (int i=0; i < RUNS; i++) localMethod(); 227 stopChronometer(); 228 229 if (useProse) ProseSystem.getAspectManager().withdraw(aspect1); 230 231 if(checkAssert) assertEquals("Hook notifications", 20, field); 232 } 233 234 public void test_the_rejit_overhead_for_MethodEntry_2() 236 { 237 if (useProse) ProseSystem.getAspectManager().insert(aspect1); 238 239 startChronometer(); 240 for (int i=0; i < RUNS; i++) localMethod(); 241 stopChronometer(); 242 243 if (useProse) ProseSystem.getAspectManager().withdraw(aspect1); 244 245 if(checkAssert) assertEquals("Hook notifications", 20, field); 246 } 247 248 249 251 public void test_the_rejit_overhead_for_MethodExit_1() 253 { 254 if (useProse) ProseSystem.getAspectManager().insert(aspect2); 255 256 startChronometer(); 257 for (int i=0; i < RUNS; i++) localMethod(); 258 stopChronometer(); 259 260 if (useProse) ProseSystem.getAspectManager().withdraw(aspect2); 261 262 if(checkAssert) assertEquals("Hook notifications", 30, field); 263 } 264 265 266 public void test_the_rejit_overhead_for_MethodExit_2() 268 { 269 if (useProse) ProseSystem.getAspectManager().insert(aspect2); 270 271 startChronometer(); 272 for (int i=0; i < RUNS; i++) localMethod(); 273 stopChronometer(); 274 275 if (useProse) ProseSystem.getAspectManager().withdraw(aspect2); 276 277 if(checkAssert) assertEquals("Hook notifications", 30, field); 278 } 279 280 281 283 public void test_the_rejit_overhead_for_MethodRedefinition_1() 285 { 286 if (useProse) ProseSystem.getAspectManager().insert(aspect3); 287 288 startChronometer(); 289 for (int i=0; i < RUNS; i++) localMethod(); 290 stopChronometer(); 291 292 if (useProse) ProseSystem.getAspectManager().withdraw(aspect3); 293 294 if(checkAssert) assertEquals("Hook notifications", 40, field); 295 } 296 297 298 public void test_the_rejit_overhead_for_MethodRedefinition_2() 300 { 301 if (useProse) ProseSystem.getAspectManager().insert(aspect3); 302 303 startChronometer(); 304 for (int i=0; i < RUNS; i++) localMethod(); 305 stopChronometer(); 306 307 if (useProse) ProseSystem.getAspectManager().withdraw(aspect3); 308 309 if(checkAssert) assertEquals("Hook notifications", 40, field); 310 } 311 312 313 315 public void test_the_rejit_overhead_for_FieldAccess_1() 317 { 318 if (useProse) ProseSystem.getAspectManager().insert(aspect4); 319 320 startChronometer(); 321 for (int i=0; i < RUNS; i++) otherMethod(); 322 stopChronometer(); 323 324 if (useProse) ProseSystem.getAspectManager().withdraw(aspect4); 325 326 if(checkAssert) assertEquals("Hook notifications", 50, field); 327 } 328 329 330 public void test_the_rejit_overhead_for_FieldAccess_2() 332 { 333 if (useProse) ProseSystem.getAspectManager().insert(aspect4); 334 335 startChronometer(); 336 for (int i=0; i < RUNS; i++) otherMethod(); 337 stopChronometer(); 338 339 if (useProse) ProseSystem.getAspectManager().withdraw(aspect4); 340 341 if(checkAssert) assertEquals("Hook notifications", 50, field); 342 } 343 344 345 347 public void test_the_rejit_overhead_for_FieldModification_1() 349 { 350 if (useProse) ProseSystem.getAspectManager().insert(aspect5); 351 352 startChronometer(); 353 for (int i=0; i < RUNS; i++) localMethod(); 354 stopChronometer(); 355 356 if (useProse) ProseSystem.getAspectManager().withdraw(aspect5); 357 358 if(checkAssert) assertEquals("Hook notifications", 60, field); 359 } 360 361 public void test_the_rejit_overhead_for_FieldModification_2() 363 { 364 if (useProse) ProseSystem.getAspectManager().insert(aspect5); 365 366 startChronometer(); 367 for (int i=0; i < RUNS; i++) localMethod(); 368 stopChronometer(); 369 370 if (useProse) ProseSystem.getAspectManager().withdraw(aspect5); 371 372 if(checkAssert) assertEquals("Hook notifications", 60, field); 373 } 374 375 379 public static Test suite() { 380 return new PerformanceTestSuite(JoinPointMeasurements2_rejitOverhead2.class); 381 } 382 } | Popular Tags |