DI/IoC 容器性能基准比较?

发布于 2024-10-22 12:47:41 字数 257 浏览 8 评论 0原文

我发现了一些 2008 年基准测试结果,用于测试几个顶级 .NET DI/IoC 容器的性能此处。但我还没有找到任何更新的结果。是否有任何基准可以比较一些大型 IoC 容器(StructureMap、Unity、Ninject、Autofac、Castle Windsor 等)?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱冒险 2024-10-29 12:47:41

我不建议使用性能基准来选择 IoC 容器。还有很多很多更重要的因素,例如功能集、开发路线图和可维护性等。

请注意,您引用的基准在最坏的情况下,仅显示超过 100 万次调用的速度差异 3-4 倍。在“现实世界”场景中,DI/IoC 用于连接依赖项,并且对整体应用程序性能的影响非常小,因为此构建阶段只占整个运行时的一小部分。选择“高性能”与“低性能”IoC 容器可能不会对应用程序的感知性能产生明显影响。

在性能对您的特定使用案例确实很重要的情况下(不太可能发生),基准不太可能成为衡量 IoC 容器性能如何影响您的有效衡量标准,因为基准往往偏向于特定问题集。如果您确实认为这是一个严重的问题,我强烈建议您自己进行分析和测量。

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.

叫嚣ゝ 2024-10-29 12:47:41

就我而言,IoC 容器的速度是一个重要因素。我有一个执行多次注入的应用程序,发现 Ninject 大大减慢了应用程序的速度。去掉IoC就彻底解决了性能问题。我将研究其他解决方案。

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.

夜未央樱花落 2024-10-29 12:47:41

IoC 容器基准 - 性能比较有 20 多种产品的性能和功能比较表,并且是最新的(最新更新 2017 年 12 月 21 日)

文章的结论:

特别是Simple Injector似乎是一个不错的选择。速度非常快,
有很好的文档并且还支持高级场景,例如
拦截和通用装饰器。

另请参阅相关https://stackoverflow.com/questions/1140730/net-di-containers-comparison/问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文