01: package test.performance;
02:
03: import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
04:
05: public class InlineBench {
06: private int m_nrInvocations = 1000000000;
07:
08: public void run() {
09: 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
15: / (double) m_nrInvocations;
16:
17: toAdvise();
18:
19: startTime = System.currentTimeMillis();
20: for (int i = 0; i < m_nrInvocations; i++) {
21: toAdvise();
22: }
23: time = System.currentTimeMillis() - startTime;
24: double timePerInvocation = time / (double) m_nrInvocations;
25: double overhead = timePerInvocation
26: - timePerInvocationNormalMethod;
27: System.out.println("\nOverhead: " + overhead);
28: }
29:
30: public static void main(String[] args) {
31: new InlineBench().run();
32: }
33:
34: public void toAdvise() {
35: }
36:
37: public void notAdvised() {
38: }
39:
40: public static class Aspect {
41: public void before(JoinPoint jp) throws Throwable {
42: }
43: }
44: }
|