}
end = System.currentTimeMillis();
printResults("FastClass", end, start, iterations);
// start a kernel
Kernel kernel = KernelFactory.newInstance().createKernel("speed");
kernel.boot();
AbstractName abstractName = kernel.getNaming().createRootName(new Artifact("test", "foo", "1", "car"), "test", "test");
GBeanData mockGBean = new GBeanData(abstractName, MockGBean.getGBeanInfo());
mockGBean.setAttribute("Name", "bar");
mockGBean.setAttribute("FinalInt", new Integer(57));
kernel.loadGBean(mockGBean, Speed.class.getClassLoader());
kernel.startGBean(abstractName);
// reflect proxy
// ProxyFactory vmProxyFactory = new VMProxyFactory(MyInterface.class);
// ProxyMethodInterceptor vmMethodInterceptor = vmProxyFactory.getMethodInterceptor();
// MyInterface vmProxy = (MyInterface) vmProxyFactory.create(vmMethodInterceptor);
// vmMethodInterceptor.connect(kernel.getMBeanServer(), objectName);
// iterations = 50000;
// for (int i = 0; i < iterations; i++) {
// vmProxy.doNothing();
// }
// start = System.currentTimeMillis();
// for (int i = 0; i < iterations; i++) {
// vmProxy.doNothing();
// }
// end = System.currentTimeMillis();
// printResults("ReflectionProxy", end, start, iterations);
// cglib proxy (front half)
/*
ProxyFactory frontCGLibProxyFactory = new CGLibProxyFactory(MyInterface.class);
ProxyMethodInterceptor frontCGLibMethodInterceptor = new ProxyMethodInterceptor(MyInterface.class);
Class enhancedType = frontCGLibProxyFactory.create(frontCGLibMethodInterceptor).getClass();
frontCGLibMethodInterceptor = new ProxyMethodInterceptor(enhancedType) {
public Object intercept(Object object, Method method, Object[] args, MethodProxy proxy) throws Throwable {
return null;
}
};
MyInterface frontCGLibProxy = (MyInterface) frontCGLibProxyFactory.create(frontCGLibMethodInterceptor);
frontCGLibMethodInterceptor.connect(kernel.getMBeanServer(), objectName);
iterations = 100000000;
for (int i = 0; i < iterations; i++) {
frontCGLibProxy.doNothing();
}
start = System.currentTimeMillis();
for (int i = 0; i < iterations; i++) {
frontCGLibProxy.doNothing();
}
end = System.currentTimeMillis();
printResults("Front CGLibProxy", end, start, iterations);
*/
// Raw Invoker
RawInvoker rawInvoker = (RawInvoker) kernel.getAttribute(mockGBean.getAbstractName(), "$$RAW_INVOKER$$");
int rawIndex = ((Integer) rawInvoker.getOperationIndex().get(new GOperationSignature("doNothing", new String[0]))).intValue();
iterations = 2000000;
for (int i = 0; i < iterations; i++) {
rawInvoker.invoke(rawIndex, NO_ARGS);
}