问题描述
做了.NET程序集的大小会影响性能呢?如何组件的Windows窗体/ Web表单的项目有多少?
Does the size of a .net assembly affect performance at all? How about the number of assemblies in your windows forms/web forms project?
推荐答案
从微软的模式与放大器;实践提高.NET应用程序性能和可伸缩性第5章:
From Microsoft's Patterns & Practices Improving .NET Application Performance and Scalability Chapter 5:
preFER单大型装配体而不是多个较小的组件
Prefer Single Large Assemblies Rather Than MultipleSmaller Assemblies
要帮助减少应用程序的工作集,你应该preFER单个较大组件而不是多个较小的组件。如果你有多个组件这总是装在一起,就应该将它们结合起来,创造一个单一的部件。
To help reduce your application’s working set, you should prefer single largerassemblies rather than multiple smaller assemblies. If you have several assembliesthat are always loaded together, you should combine them and create a singleassembly.
与具有多个较小的组件相关联的开销可以归因以下内容:
The overhead associated with having multiple smaller assemblies can be attributedto the following:
- 加载元数据较小的组件的成本。
- 在谈到在pre-编译图像的各种内存页的CLR为了加载组件(如果它是pcompiled与Ngen.exe $ P $)。
- 在JIT编译时间。
- 安全检查。
- The cost of loading metadata for smaller assemblies.
- Touching various memory pages in pre-compiled images in the CLR in orderto load the assembly (if it is precompiled with Ngen.exe).
- JIT compile time.
- Security checks.
由于你付出的只是你的程序访问内存页面,更大组件提供本机图像生成实用器(Ngen.exe)具有较大机会来优化它产生的本机映像。图像手段更好的布局必要的数据,可以更密集地布置,而这又意味着更少的整体需要的页面做的工作相比,同样code多布局组件。
Because you pay for only the memory pages your program accesses, largerassemblies provide the Native Image Generator utility (Ngen.exe) with a greaterchance to optimize the native image it produces. Better layout of the image meansthat necessary data can be laid out more densely, which in turn means fewer overallpages are needed to do the job compared to the same code laid out in multipleassemblies.
有时候你无法避免分裂组件;例如,对于版本和部署的原因。如果你需要单独船型,您可能需要单独组件。
Sometimes you cannot avoid splitting assemblies; for example, for versioning anddeployment reasons. If you need to ship types separately, you may need separateassemblies.
这篇关于是否.NET程序集的大小会影响性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!