Source Code Cross Referenced for JoinPointMeasurements2_rejitOverhead2.java in  » Byte-Code » PROSE » measurements » suites » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Byte Code » PROSE » measurements.suites 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package measurements.suites;
002:
003:        import junit.framework.Assert;
004:        import junit.framework.Test;
005:        import ch.ethz.prose.DefaultAspect;
006:        import ch.ethz.prose.Aspect;
007:        import ch.ethz.prose.ProseSystem;
008:        import ch.ethz.prose.crosscut.Crosscut;
009:        import ch.ethz.prose.crosscut.MethodCut;
010:        import ch.ethz.prose.crosscut.MethodRedefineCut;
011:        import ch.ethz.prose.crosscut.GetCut;
012:        import ch.ethz.prose.crosscut.SetCut;
013:        import ch.ethz.prose.filter.Fields;
014:        import ch.ethz.prose.filter.PointCutter;
015:        import ch.ethz.prose.filter.Executions;
016:        import ch.ethz.prose.filter.Within;
017:        import ch.ethz.inf.util.junit.PerformanceTest;
018:        import ch.ethz.inf.util.junit.PerformanceTestSuite;
019:
020:        //import ch.ethz.prose.jikesrvm.JikesRVMPerformanceTest;
021:
022:        /**
023:         *  JoinPoint measurements
024:         * 
025:         * Performance tests to calculate the relative rejit overhead 
026:         * after the aspect has been inserted.
027:         * 
028:         * @version	$Revision: 1.1 $
029:         * @author	Angela Nicoara
030:         */
031:        public class JoinPointMeasurements2_rejitOverhead2 extends
032:                PerformanceTest {
033:            //public class JoinPointMeasurements2_rejitOverhead2 extends JikesRVMPerformanceTest {
034:
035:            public int x;
036:            public int y = 10;
037:            public int z;
038:            public int field = 0;
039:            public boolean checkAssert = true;
040:
041:            public void localMethod() {
042:                x = 1; //set the "x" field
043:                //System.err.println("LocalMethod");
044:            }
045:
046:            public void otherMethod() {
047:                z = y; // get the "y" field
048:                //System.err.println("OtherMethod");
049:            }
050:
051:            // METHOD ENTRY
052:            public class MethodEntryAspect extends DefaultAspect {
053:                public Crosscut c1 = new MethodCut() {
054:                    // execute the advice 'before' the method 'localMethod' 
055:                    public void METHOD_ARGS(
056:                            JoinPointMeasurements2_rejitOverhead2 target) {
057:                        //int q;
058:                        //q = 20;
059:                        target.field = 20;
060:                    }
061:
062:                    // .. && calls(* localMethod())
063:                    protected PointCutter pointCutter() {
064:                        return ((Executions.before()).AND(Within
065:                                .method("localMethod")).AND(Within
066:                                .type("JoinPointMeasurements2_rejitOverhead2")));
067:                    }
068:                };
069:            }
070:
071:            // METHOD EXIT
072:            public class MethodExitAspect extends DefaultAspect {
073:                public Crosscut c2 = new MethodCut() {
074:                    // execute the advice 'after' the method 'localMethod' 
075:                    public void METHOD_ARGS(
076:                            JoinPointMeasurements2_rejitOverhead2 target) {
077:                        //int q;
078:                        //q = 30;
079:                        target.field = 30;
080:                    }
081:
082:                    // .. && calls(* localMethod())
083:                    protected PointCutter pointCutter() {
084:                        return ((Executions.after()).AND(Within
085:                                .method("localMethod")).AND(Within
086:                                .type("JoinPointMeasurements2_rejitOverhead2")));
087:                    }
088:                };
089:            }
090:
091:            // METHOD REDEFINITION
092:            public class MethodRedefineAspect extends DefaultAspect {
093:                public Crosscut c3 = new MethodRedefineCut() {
094:                    // the body of new method
095:                    public void METHOD_ARGS(
096:                            JoinPointMeasurements2_rejitOverhead2 target) {
097:                        //int q;
098:                        //q = 40;
099:                        target.field = 40;
100:                    }
101:
102:                    protected PointCutter pointCutter() {
103:                        return ((Within.method("localMethod")).AND(Within
104:                                .type("JoinPointMeasurements2_rejitOverhead2")));
105:                    }
106:                };
107:            }
108:
109:            // FIELD ACCESS
110:            public class FieldAccessAspect extends DefaultAspect {
111:                public Crosscut c4 = new GetCut() {
112:                    //public void GET_ARGS()   //EMPTY -> equivalent with GET_ARGS(ANY,ANY)
113:                    public void GET_ARGS(
114:                            JoinPointMeasurements2_rejitOverhead2 target, int x) //CONCRETE__CONCRETE
115:                    //public void GET_ARGS(ANY obj, double x) //WILDCARD__CONCRETE
116:                    //public void GET_ARGS(ANY obj, ANY x)    //WILDCARD__WILDCARD -> equivalent with GET_ARGS()
117:                    {
118:                        //int q;
119:                        //q = 50;
120:                        target.field = 50;
121:                    }
122:
123:                    protected PointCutter pointCutter() {
124:                        return ((Fields.named("y.*"))
125:                                .AND(Fields
126:                                        .declaredInClass("JoinPointMeasurements2_rejitOverhead2")));
127:                    }
128:                };
129:            }
130:
131:            // FIELD MODIFICATION
132:            public class FieldModificationAspect extends DefaultAspect {
133:                public Crosscut c5 = new SetCut() {
134:                    //public void SET_ARGS()   //EMPTY -> equivalent with GET_ARGS(ANY,ANY)
135:                    public void SET_ARGS(
136:                            JoinPointMeasurements2_rejitOverhead2 target, int x) //CONCRETE__CONCRETE
137:                    //public void SET_ARGS(ANY obj, double x) //WILDCARD__CONCRETE
138:                    //public void SET_ARGS(ANY obj, ANY x)    //WILDCARD__WILDCARD -> equivalent with GET_ARGS()
139:                    {
140:                        //int q;
141:                        //q = 60;
142:                        target.field = 60;
143:                    }
144:
145:                    protected PointCutter pointCutter() {
146:                        return (Fields.named("x.*")
147:                                .AND(Fields
148:                                        .declaredInClass("JoinPointMeasurements2_rejitOverhead2")));
149:                    }
150:                };
151:            }
152:
153:            Aspect aspect1; // METHOD ENTRY
154:            Aspect aspect2; // METHOD EXIT
155:            Aspect aspect3; // METHOD REDEFINITION
156:            Aspect aspect4; // FIELD ACCESS
157:            Aspect aspect5; // FIELD MODIFICATION
158:
159:            public boolean useProse = false;
160:
161:            /**
162:             * Construct test with given name.
163:             * @param name test name
164:             */
165:            public JoinPointMeasurements2_rejitOverhead2(String name) {
166:                super (name);
167:                //RANGE = new int[] { 1 };
168:                RANGE = new int[] { 100000 };
169:
170:                String proseParam = System.getProperty("useprose");
171:                if (proseParam != null)
172:                    useProse = true;
173:            }
174:
175:            /**
176:             * Set up fixture.
177:             */
178:            protected void setUp() {
179:                if (!useProse)
180:                    return;
181:
182:                try {
183:                    ProseSystem.startup();
184:                } catch (Exception e) {
185:                    Assert.fail("ProseSystem.startup() failed");
186:                }
187:
188:                aspect1 = new MethodEntryAspect();
189:                aspect2 = new MethodExitAspect();
190:                aspect3 = new MethodRedefineAspect();
191:                aspect4 = new FieldAccessAspect();
192:                aspect5 = new FieldModificationAspect();
193:
194:                field = 0;
195:            }
196:
197:            protected void tearDown() {
198:                if (!useProse)
199:                    return;
200:
201:                try {
202:                    ProseSystem.teardown();
203:                } catch (Exception e) {
204:                    Assert.fail("ProseSystem.teardown() failed");
205:                }
206:            }
207:
208:            //========= METHOD ENTRY =========
209:
210:            // the rejit overhead is included
211:            public void test_the_rejit_overhead_for_MethodEntry_1() {
212:                if (useProse)
213:                    ProseSystem.getAspectManager().insert(aspect1);
214:
215:                startChronometer();
216:                for (int i = 0; i < RUNS; i++)
217:                    localMethod();
218:                stopChronometer();
219:
220:                if (useProse)
221:                    ProseSystem.getAspectManager().withdraw(aspect1);
222:
223:                if (checkAssert)
224:                    assertEquals("Hook notifications", 20, field);
225:            }
226:
227:            // the rejit overhead isn't included
228:            public void test_the_rejit_overhead_for_MethodEntry_2() {
229:                if (useProse)
230:                    ProseSystem.getAspectManager().insert(aspect1);
231:
232:                startChronometer();
233:                for (int i = 0; i < RUNS; i++)
234:                    localMethod();
235:                stopChronometer();
236:
237:                if (useProse)
238:                    ProseSystem.getAspectManager().withdraw(aspect1);
239:
240:                if (checkAssert)
241:                    assertEquals("Hook notifications", 20, field);
242:            }
243:
244:            //========= METHOD EXIT =========
245:
246:            // the rejit overhead is included
247:            public void test_the_rejit_overhead_for_MethodExit_1() {
248:                if (useProse)
249:                    ProseSystem.getAspectManager().insert(aspect2);
250:
251:                startChronometer();
252:                for (int i = 0; i < RUNS; i++)
253:                    localMethod();
254:                stopChronometer();
255:
256:                if (useProse)
257:                    ProseSystem.getAspectManager().withdraw(aspect2);
258:
259:                if (checkAssert)
260:                    assertEquals("Hook notifications", 30, field);
261:            }
262:
263:            // the rejit overhead isn't included
264:            public void test_the_rejit_overhead_for_MethodExit_2() {
265:                if (useProse)
266:                    ProseSystem.getAspectManager().insert(aspect2);
267:
268:                startChronometer();
269:                for (int i = 0; i < RUNS; i++)
270:                    localMethod();
271:                stopChronometer();
272:
273:                if (useProse)
274:                    ProseSystem.getAspectManager().withdraw(aspect2);
275:
276:                if (checkAssert)
277:                    assertEquals("Hook notifications", 30, field);
278:            }
279:
280:            //========= METHOD REDEFINITION =========
281:
282:            // the rejit overhead is included
283:            public void test_the_rejit_overhead_for_MethodRedefinition_1() {
284:                if (useProse)
285:                    ProseSystem.getAspectManager().insert(aspect3);
286:
287:                startChronometer();
288:                for (int i = 0; i < RUNS; i++)
289:                    localMethod();
290:                stopChronometer();
291:
292:                if (useProse)
293:                    ProseSystem.getAspectManager().withdraw(aspect3);
294:
295:                if (checkAssert)
296:                    assertEquals("Hook notifications", 40, field);
297:            }
298:
299:            // the rejit overhead isn't included
300:            public void test_the_rejit_overhead_for_MethodRedefinition_2() {
301:                if (useProse)
302:                    ProseSystem.getAspectManager().insert(aspect3);
303:
304:                startChronometer();
305:                for (int i = 0; i < RUNS; i++)
306:                    localMethod();
307:                stopChronometer();
308:
309:                if (useProse)
310:                    ProseSystem.getAspectManager().withdraw(aspect3);
311:
312:                if (checkAssert)
313:                    assertEquals("Hook notifications", 40, field);
314:            }
315:
316:            //========= FIELD ACCESS =========
317:
318:            // the rejit overhead is included
319:            public void test_the_rejit_overhead_for_FieldAccess_1() {
320:                if (useProse)
321:                    ProseSystem.getAspectManager().insert(aspect4);
322:
323:                startChronometer();
324:                for (int i = 0; i < RUNS; i++)
325:                    otherMethod();
326:                stopChronometer();
327:
328:                if (useProse)
329:                    ProseSystem.getAspectManager().withdraw(aspect4);
330:
331:                if (checkAssert)
332:                    assertEquals("Hook notifications", 50, field);
333:            }
334:
335:            // the rejit overhead isn't included
336:            public void test_the_rejit_overhead_for_FieldAccess_2() {
337:                if (useProse)
338:                    ProseSystem.getAspectManager().insert(aspect4);
339:
340:                startChronometer();
341:                for (int i = 0; i < RUNS; i++)
342:                    otherMethod();
343:                stopChronometer();
344:
345:                if (useProse)
346:                    ProseSystem.getAspectManager().withdraw(aspect4);
347:
348:                if (checkAssert)
349:                    assertEquals("Hook notifications", 50, field);
350:            }
351:
352:            //========= FIELD MODIFICATION =========
353:
354:            // the rejit overhead is included
355:            public void test_the_rejit_overhead_for_FieldModification_1() {
356:                if (useProse)
357:                    ProseSystem.getAspectManager().insert(aspect5);
358:
359:                startChronometer();
360:                for (int i = 0; i < RUNS; i++)
361:                    localMethod();
362:                stopChronometer();
363:
364:                if (useProse)
365:                    ProseSystem.getAspectManager().withdraw(aspect5);
366:
367:                if (checkAssert)
368:                    assertEquals("Hook notifications", 60, field);
369:            }
370:
371:            // the rejit overhead isn't included
372:            public void test_the_rejit_overhead_for_FieldModification_2() {
373:                if (useProse)
374:                    ProseSystem.getAspectManager().insert(aspect5);
375:
376:                startChronometer();
377:                for (int i = 0; i < RUNS; i++)
378:                    localMethod();
379:                stopChronometer();
380:
381:                if (useProse)
382:                    ProseSystem.getAspectManager().withdraw(aspect5);
383:
384:                if (checkAssert)
385:                    assertEquals("Hook notifications", 60, field);
386:            }
387:
388:            /**
389:             * Test suite.
390:             * @return test instance
391:             */
392:            public static Test suite() {
393:                return new PerformanceTestSuite(
394:                        JoinPointMeasurements2_rejitOverhead2.class);
395:            }
396:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.