David Hoerster
David Hoerster

Reputation: 28701

DI/IoC Container Performance Benchmark Comparison?

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.)?

Upvotes: 15

Views: 9569

Answers (3)

Michael Freidgeim
Michael Freidgeim

Reputation: 28435

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.

Upvotes: 6

Sachin Kainth
Sachin Kainth

Reputation: 46750

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.

Upvotes: 6

Reed Copsey
Reed Copsey

Reputation: 564413

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.

Upvotes: 45

Related Questions