|
|||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Performance Test (Nuts vs Spring)
In this article you will see a simple performance test on the simplest use of Spring and Nuts. We will compare simple bean without injection, constructor injection, setter injection, singleton bean, prototype bean and spring aop interceptor. All Spring test cases repeatedly call "getBean()" hundreds of thousands of times against a Spring XMLBeanFactory object. Since Yan provides a "getFactory()" method that's useful when the same Factory object is used multiple times, we'll call "getInstance()" and "getFactory()" in different test cases. To give you a quick sense of the test case, the Spring test cases all look like: for(...){
beanfactory.getBean(beanname);
}
While the Nuts test cases are like: for(...){
container.getInstance(beanname);
}
The Nuts test cases calling "getFactory()" are: Factory factory = container.getFactory(beanname);
for(...){
factory.create();
}
Since Nuts doesn't provide an out-of-the-box AOP solution (we don't want to re-invent wheels unless necessary), Spring is integrated into Nuts to get the test data on AOP. Therefore, we have a seperate set of test cases for Nuts performance when Spring is integrated. This benchmark is by no means complete nor 100% accurate. I'm no expert on software benchmarking. My laptop is slow and short of memory (only 1G). Lots of advanced features of Spring and Nuts are not covered. The test models are also very simple in the sense that not too many dependencies need to be injected. And here goes the test result:
For Nuts speed, in addition to the "call per sec" number, we also give the ratio of Nuts speed to the Spring speed. This test is based on the Spring version 1.2.6. (We did a comparison on Spring 1.1.4 as well, 1.1.4 appeared to be a bit faster than 1.2.6.) As you can see, Nuts Spring Integration performs a bit slower for Spring AOP than Spring. Other than that, Nuts is faster than Spring (with or without Spring Integration) in all other test cases. The ratio ranges from 3 times to 29 times faster. The following are the test cases: |
|||||||||||||||||||||||||||||||||||||||||||||||||
|
Copyright 2003-2006 - The Codehaus. All rights reserved unless otherwise noted.
Powered by Atlassian Confluence
|
|||||||||||||||||||||||||||||||||||||||||||||||||