在 Unity 2.0 中创建子容器对性能的影响
在 Unity 2.0 中创建子容器的成本有多大(性能影响)?例如,该场景是 Web 应用程序或 Web 服务,其中主容器在应用程序启动时初始化,但每个处理的请求都有其自己的从主容器创建的子容器实例。容器的配置不会改变。原因是使用了 HierarchicalLifetimeManager。
How costly (performance impact) is creating subcontainers in Unity 2.0? The scenario is for example web application or web service where main container is initialized on start of the application but each processed request has its own instace of subcontainer created from the main one. The configuration of the container will not change. The reason is usage of HierarchicalLifetimeManager
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与往常一样,当问题与性能相关时,答案是:测量您的应用程序以了解特定应用程序的性能影响。
一般来说,对于与进程外资源(例如数据库、Web 服务等)集成的主流应用程序来说,对象组合很少是性能瓶颈。 自信地编写对象图 - DI 容器很可能不会给你一个可衡量的开销。
As always when the question is related to performance the answer is: measure your application to understand the performance implications for your specific application.
As a general observation, for mainstream applications that integrate with out-of-process resources (such as databases, web services, etc.), object composition is rarely a performance bottleneck. Compose your object graphs with confidence - odds are that the DI Container will not give you a measurable overhead.