I made quick comparison of performance of four DI/IoC containers. I measured Unity, Castle Windsor, StructureMap and Ninject in two scenarios – resolving objects with empty constructor and resolving object with injected parameters in its constructor. Results are here.
As a first thing I made carefully sure that objects are created when resolve methods are called. The results for resolving object with default constructor by interface are here.
In second round I let mappers resolve type that needs constructor parameters and these parameters were injected my DI/IoC containers. Times changed a little bit but TOP4 stayed the same.
Here are comparison chart of results for both measurements.
StructureMap that is old veteran on field when considering .NET gives best results. Unity and Castle Windsor have also good results although Unity works faster in more complex scenarios. Ninject was slowest, although they use lightweight code generation (LCG). You can also read about my object to object mapper experiment and LCG to get better idea what LCG is all about.
Currently, I think, I will stick with StructureMap as they also have pretty good fluent API that was asy to learn and easy to use. I also hope that other competitors give better results in their next versions.
Update 1: Autofac gave me the following results - 9 and 16 for first and second test. So it seems like they are fastest ones. Thanks for suggestion, Robert!
Update 2: Units on charts are ticks. It is average over one million calls to pre-warmed resolve.