DI/IoC 容器性能基准比较? [英] DI/IoC Container Performance Benchmark Comparison?

查看:37
本文介绍了DI/IoC 容器性能基准比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一些 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.)?

推荐答案

我不建议使用性能基准来选择 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.

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

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.

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

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.

这篇关于DI/IoC 容器性能基准比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆