KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > performance > InlineBench


1 package test.performance;
2
3 import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
4
5 public class InlineBench {
6     private int m_nrInvocations = 1000000000;
7
8     public void run() {
9         long startTime = System.currentTimeMillis();
10         for (int i = 0; i < m_nrInvocations; i++) {
11             notAdvised();
12         }
13         long time = System.currentTimeMillis() - startTime;
14         double timePerInvocationNormalMethod = time / (double) m_nrInvocations;
15
16         toAdvise();
17
18         startTime = System.currentTimeMillis();
19         for (int i = 0; i < m_nrInvocations; i++) {
20             toAdvise();
21         }
22         time = System.currentTimeMillis() - startTime;
23         double timePerInvocation = time / (double) m_nrInvocations;
24         double overhead = timePerInvocation - timePerInvocationNormalMethod;
25         System.out.println("\nOverhead: " + overhead);
26     }
27
28     public static void main(String JavaDoc[] args) {
29         new InlineBench().run();
30     }
31
32     public void toAdvise() {
33     }
34
35     public void notAdvised() {
36     }
37
38     public static class Aspect {
39         public void before(JoinPoint jp) throws Throwable JavaDoc {
40         }
41     }
42 }
Popular Tags