DecimalFormat format = new DecimalFormat("00000");
MethodInterceptor interceptor = new GreetInterceptor();
long start = System.currentTimeMillis();
for (int i = 0; i < times; i++) {
final Class clazz = Class.forName("xxx.NullBean" + format.format(i));
Pointcut pointcut = new PointcutImpl(new String[] { "toString" });
Aspect aspect = new AspectImpl(interceptor, pointcut);
AopProxy aopProxy = new AopProxy(clazz, new Aspect[] { aspect });
Object proxy = aopProxy.create();
}
long end = System.currentTimeMillis();
// end - startを記録
プログラム(Spring)
DecimalFormat format = new DecimalFormat("00000");
Advice advice = new GreetInterceptor();
JdkRegexpMethodPointcut pointcut = new JdkRegexpMethodPointcut();
pointcut.setPattern(".*toString");
DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(pointcut, advice);
long start = System.currentTimeMillis();
for (int i = 0; i < times; i++) {
final Class clazz = Class.forName("xxx.NullBean" + format.format(i));
Object instance = clazz.newInstance();
ProxyFactory factory = new ProxyFactory(instance);
factory.setProxyTargetClass(true);
factory.addAdvisor(advisor);
Object proxy = factory.getProxy();
}
long end = System.currentTimeMillis();
// end - startを記録