I've found some 2008 benchmark results for testing the performance of several of the top .NET DI/IoC containers here. But I haven't been able to find any updated results. Are there any benchmarks out there that compare some of the big IoC containers (StructureMap, Unity, Ninject, Autofac, Castle Windsor, etc.)?

- 73,706
- 19
- 184
- 253

- 28,421
- 8
- 67
- 102
-
I agree with Reed. Besides, benchmarks are easy to get wrong. Look for instance at this thread: http://stackoverflow.com/questions/5298240/hiro-vs-other-ioc-containers/5308894#5308894. – Steven Mar 15 '11 at 20:33
-
1The fact that such new benchmarks are missing from the net, I take as a statement that this is of lesser concern. – Peter Lillevold Mar 15 '11 at 20:44
3 Answers
I would not recommend using performance benchmarks to pick an IoC container. There are many, many more important factors, such as feature set, development roadmap and maintainability, etc.
Realize that the benchmark you're citing is, in the worst case, only showing a 3-4x difference in speed over 1 million calls. In a "real world" scenario, DI/IoC is used to wire up dependencies, and will have a very minimal impact on overall application performance, as this construction phase is an incredibly small portion of your overall runtime. Choosing a "high performance" vs. a "low performance" IoC container will likely have no discernible impact on your application's perceived performance.
In the unlikely scenario that performance is truly important to your specific usage case, a benchmark is unlikely to be a valid measure of how the IoC container's performance will impact you, as benchmarks tend to be skewed towards a specific problem set. I would highly recommend doing your own profiling and measurement if you truly believe this is a serious issue.

- 554,122
- 78
- 1,158
- 1,373
-
6Just chiming in to say that Choosing a high performance vs. low performance IoC container can have a huge discernible impact on an application's perceived performance, as the smallest discernible change by a user is 50ms, and the performance differences between the best and worst containers is often WAY more than 50ms. We personally moved from Ninject to DryIoC 2.1.3 for this very reason. – John Zabroski Feb 23 '16 at 16:02
-
13-4x differences are not what updated benchmarks are showing. For instance, Ninject vs LightInject difference can be more than 200x, according to http://www.palmmedia.de/blog/2011/8/30/ioc-container-benchmark-performance-comparison – daniloquio Mar 07 '18 at 19:04
In my case, speed of IoC container has been an important factor. I've had an application that performs many injections and found that Ninject was slowing the application down considerably. Taking out the IoC completely solved the performance issues. I will be looking into other solutions.

- 45,256
- 81
- 201
- 304
-
If taking out the IoC container solved the performance issues, you might want to try [Simple Injector](https://simpleinjector.codeplex.com/). The performance overhead of Simple Injector compared to newing up object graphs by hand is minimal (and sometimes even better) as can be seen in [this benchmark](http://www.palmmedia.de/blog/2011/8/30/ioc-container-benchmark-performance-comparison). – Steven Sep 03 '13 at 10:47
-
IoC Container Benchmark - Performance comparison has performance and features comparison tables for 20+ products and it is up-to-date (latest update 21.12.2017)
The conclusion from the article:
Especially Simple Injector seems to be a good choice. It's very fast, has a good documentation and also supports advanced scenarios like interception and generic decorators.
See also related https://stackoverflow.com/questions/1140730/net-di-containers-comparison/ question.

- 26,542
- 16
- 152
- 170