Source Code Cross Referenced for PerformanceTest.java in  » Aspect-oriented » aspectwerkz-2.0 » test » performance » 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 » Aspect oriented » aspectwerkz 2.0 » test.performance 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**************************************************************************************
002:         * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved.                 *
003:         * http://aspectwerkz.codehaus.org                                                    *
004:         * ---------------------------------------------------------------------------------- *
005:         * The software in this package is published under the terms of the LGPL license      *
006:         * a copy of which has been included with this distribution in the license.txt file.  *
007:         **************************************************************************************/package test.performance;
008:
009:        import junit.framework.TestCase;
010:
011:        /**
012:         * A so far VERY limited bench. <p/>Only tests the overhead of one around advice and one introduced
013:         * method.
014:         *
015:         * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
016:         * @TODO: extends this test case to be more interesting or replace with a real bench
017:         * @TODO: should add some more around advice, since JIT really shines when we have advice chains
018:         */
019:        public class PerformanceTest extends TestCase {
020:            private boolean m_printInfo = true;
021:
022:            private int m_numberOfInvocations = 100000000;
023:
024:            public PerformanceTest(String name) {
025:                super (name);
026:            }
027:
028:            public void testNonAdvisedMethodPerformance() {
029:                long startTime = System.currentTimeMillis();
030:                for (int i = 0; i < m_numberOfInvocations; i++) {
031:                    nonAdvisedMethod();
032:                }
033:                long time = System.currentTimeMillis() - startTime;
034:                double timePerInvocationNormalMethod = time
035:                        / (double) m_numberOfInvocations;
036:                if (m_printInfo) {
037:                    System.out.println("\nNon advised method: "
038:                            + timePerInvocationNormalMethod);
039:                }
040:            }
041:
042:            public void testAroundAdvicePerJVMPerformance() {
043:                methodAdvisedMethodPerJVM();
044:                long startTime = System.currentTimeMillis();
045:                for (int i = 0; i < m_numberOfInvocations; i++) {
046:                    nonAdvisedMethod();
047:                }
048:                long time = System.currentTimeMillis() - startTime;
049:                double timePerInvocationNormalMethod = time
050:                        / (double) m_numberOfInvocations;
051:                startTime = System.currentTimeMillis();
052:                for (int i = 0; i < m_numberOfInvocations; i++) {
053:                    methodAdvisedMethodPerJVM();
054:                }
055:                time = System.currentTimeMillis() - startTime;
056:                double timePerInvocation = time
057:                        / (double) m_numberOfInvocations;
058:                double overhead = timePerInvocation
059:                        - timePerInvocationNormalMethod;
060:                if (m_printInfo) {
061:                    System.out.println("\nPER_JVM advice: " + overhead);
062:                }
063:            }
064:
065:            public void testAroundAdvicePerClassPerformance() {
066:                methodAdvisedMethodPerClass();
067:                long startTime = System.currentTimeMillis();
068:                for (int i = 0; i < m_numberOfInvocations; i++) {
069:                    nonAdvisedMethod();
070:                }
071:                long time = System.currentTimeMillis() - startTime;
072:                double timePerInvocationNormalMethod = time
073:                        / (double) m_numberOfInvocations;
074:                startTime = System.currentTimeMillis();
075:                for (int i = 0; i < m_numberOfInvocations; i++) {
076:                    methodAdvisedMethodPerClass();
077:                }
078:                time = System.currentTimeMillis() - startTime;
079:                double timePerInvocation = time
080:                        / (double) m_numberOfInvocations;
081:                double overhead = timePerInvocation
082:                        - timePerInvocationNormalMethod;
083:                if (m_printInfo) {
084:                    System.out.println("\nPER_CLASS advice: " + overhead);
085:                }
086:            }
087:
088:            public void testAroundAdvicePerInstancePerformance() {
089:                methodAdvisedMethodPerInstance();
090:                long startTime = System.currentTimeMillis();
091:                for (int i = 0; i < m_numberOfInvocations; i++) {
092:                    nonAdvisedMethod();
093:                }
094:                long time = System.currentTimeMillis() - startTime;
095:                double timePerInvocationNormalMethod = time
096:                        / (double) m_numberOfInvocations;
097:                startTime = System.currentTimeMillis();
098:                for (int i = 0; i < m_numberOfInvocations; i++) {
099:                    methodAdvisedMethodPerInstance();
100:                }
101:                time = System.currentTimeMillis() - startTime;
102:                double timePerInvocation = time
103:                        / (double) m_numberOfInvocations;
104:                double overhead = timePerInvocation
105:                        - timePerInvocationNormalMethod;
106:                if (m_printInfo) {
107:                    System.out.println("\nPER_INSTANCE advice: " + overhead);
108:                }
109:            }
110:
111:            public void testAroundAdvicePerThreadPerformance() {
112:                methodAdvisedMethodPerThread();
113:                long startTime = System.currentTimeMillis();
114:                for (int i = 0; i < m_numberOfInvocations; i++) {
115:                    nonAdvisedMethod();
116:                }
117:                long time = System.currentTimeMillis() - startTime;
118:                double timePerInvocationNormalMethod = time
119:                        / (double) m_numberOfInvocations;
120:                startTime = System.currentTimeMillis();
121:                for (int i = 0; i < m_numberOfInvocations; i++) {
122:                    methodAdvisedMethodPerThread();
123:                }
124:                time = System.currentTimeMillis() - startTime;
125:                double timePerInvocation = time
126:                        / (double) m_numberOfInvocations;
127:                double overhead = timePerInvocation
128:                        - timePerInvocationNormalMethod;
129:                if (m_printInfo) {
130:                    System.out.println("\nPER_THREAD advice: " + overhead);
131:                }
132:            }
133:
134:            public void testIntroductionPerJVMPerformance() {
135:                long startTime = System.currentTimeMillis();
136:                PerJVM perJVM = (PerJVM) this ;
137:                for (int i = 0; i < m_numberOfInvocations; i++) {
138:                    perJVM.runPerJVM();
139:                }
140:                long time = System.currentTimeMillis() - startTime;
141:                double timePerInvocation = time
142:                        / (double) m_numberOfInvocations;
143:                if (m_printInfo) {
144:                    System.out.println("\nPER_JVM introduction: "
145:                            + timePerInvocation);
146:                }
147:            }
148:
149:            public void testIntroductionPerClassPerformance() {
150:                long startTime = System.currentTimeMillis();
151:                PerClass perClass = (PerClass) this ;
152:                for (int i = 0; i < m_numberOfInvocations; i++) {
153:                    perClass.runPerClass();
154:                }
155:                long time = System.currentTimeMillis() - startTime;
156:                double timePerInvocation = time
157:                        / (double) m_numberOfInvocations;
158:                if (m_printInfo) {
159:                    System.out.println("\nPER_CLASS introduction: "
160:                            + timePerInvocation);
161:                }
162:            }
163:
164:            public void testIntroductionPerInstancePerformance() {
165:                long startTime = System.currentTimeMillis();
166:                PerInstance perInstance = (PerInstance) this ;
167:                for (int i = 0; i < m_numberOfInvocations; i++) {
168:                    perInstance.runPerInstance();
169:                }
170:                long time = System.currentTimeMillis() - startTime;
171:                double timePerInvocation = time
172:                        / (double) m_numberOfInvocations;
173:                if (m_printInfo) {
174:                    System.out.println("\nPER_INSTANCE introduction: "
175:                            + timePerInvocation);
176:                }
177:            }
178:
179:            public void testIntroductionPerThreadPerformance() {
180:                long startTime = System.currentTimeMillis();
181:                PerThread perThread = (PerThread) this ;
182:                for (int i = 0; i < m_numberOfInvocations; i++) {
183:                    perThread.runPerThread();
184:                }
185:                long time = System.currentTimeMillis() - startTime;
186:                double timePerInvocation = time
187:                        / (double) m_numberOfInvocations;
188:                if (m_printInfo) {
189:                    System.out.println("\nPER_THREAD introduction: "
190:                            + timePerInvocation);
191:                }
192:            }
193:
194:            public static void main(String[] args) {
195:                junit.textui.TestRunner.run(suite());
196:            }
197:
198:            public static junit.framework.Test suite() {
199:                return new junit.framework.TestSuite(PerformanceTest.class);
200:            }
201:
202:            // ==== methods to test ====
203:            public void nonAdvisedMethod() {
204:            }
205:
206:            public void preAdvisedMethodPerJVM() {
207:            }
208:
209:            public void preAdvisedMethodPerClass() {
210:            }
211:
212:            public void preAdvisedMethodPerInstance() {
213:            }
214:
215:            public void preAdvisedMethodPerThread() {
216:            }
217:
218:            public void methodAdvisedMethodPerJVM() {
219:            }
220:
221:            public void methodAdvisedMethodPerClass() {
222:            }
223:
224:            public void methodAdvisedMethodPerInstance() {
225:            }
226:
227:            public void methodAdvisedMethodPerThread() {
228:            }
229:
230:            public void methodAdvisedMethodNoAdvice() {
231:            }
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.