I have been evangelizing the use of IoC for a number of years. Frequently the newly converted ask the following two questions:
- Which container to use?
- Which is fastest?
My answer to the first is almost always the one you choose, and for the second question I refer them to Martin From’s IoCBattleweb page. I wont get into the reason for my answer to the first question in this post (I will save that for another day). However, I have found that Martin’s web site was missing the TinyIOC container, the Caliburn.Micro.SimpleContainer, and the existing containers needed a version refresh.
Enough talk – here are the results.
These tests were performed on an Intel i7-2630QM 2.00 Ghz with 16 gb of memory running Windows 7 64-bit.
IoC Containers Tested
- Windsor v126.96.36.19901
- Ninject v188.8.131.52
- Unity v2.1.505.0
- StructureMap v2.6.3
- Autofac v184.108.40.2061
- Dynamo v1.0
- TinyIOC v1.1.1
- Caliburn.Micro.Container v1.3.1
It is important to realize that performance is not the primary criteria to use in selecting an IOC container. It is important in some cases, but overall it is just one of a number of issues that I consider a secondary concerns.
Each of these containers has strengths and weaknesses. They offer different features, and sometimes do so in different ways. Finally, they operate in different runtimes and environments.
Bottom line – spend the time to find the container that does what you need and you are comfortable with.
You can download my modified version of the source code from original IoCBattle at github.
My thanks go to Martin From for doing this test and the Dynamo IoC Container.