Most of my posts are directly Sitecore related, but this is a subject I would like to cover briefly. I have long been explaining to people that the only IoC container I have every had a REAL issue with when doing performance analysis on sites is ….. NINJECT.
During my time as a dev I have seen many a X vs Y vs Z posts, one such post was IoC Battle and then subsequently IoC Battle revisited. These posts were great, but are somewhat outdated… Things have moved on… So I thought I would take the time to post what this test is like in 2015. I updated the tests to VS2013, .net 4.5.1 and used the latest and greatest nuget packages for the appropriate container.
I also behaviour flattened Windsor since it’s (now) default behaviour for transient resolves is for container to release them, not the GC. And so… ON TO THE RESULTS!
All times are in ms.
|Singleton Reg.||Singleton Resolve (1,000,000)||Transient Reg.||Transient Resolve (1,000,000)|
|AutoFac Lambda 188.8.131.52||74.3074||435.4103||3.1436||5,925.4697|
|Castle Windsor 184.108.40.206||220.3506||353.9794||15.5518||42,269.1004|
Well, as before – Ninject appears to be by far the least performant in these tests. Castle Windsor was a little down on the competition too. I personally still favour StructureMap over Autofac (unlike some of my colleagues), it’s a preference of the API’s.
Since the majority of the resolves you are likely to do in your app’s will be transient, I would definitely (usually) choose a decent transient performance over singleton.
The updated source is here on GitHub, I would love for you guys to take it and add your favourite IoC.