CLR 2.0 VS 4.0的性能?性能、CLR、VS

由网友(twinge(刺痛))分享简介:将在运行一个.NET程序编译为CLR 2.0的运行速度更快,如果unden CLR 4.0?的app.config:< XML版本=1.0编码=UTF-8&GT?;<结构><启动>< supportedRuntime版本=v4.0.30319的SKU =NETFramework,版...

将在运行一个.NET程序编译为CLR 2.0的运行速度更快,如果unden CLR 4.0?

的app.config:

 < XML版本=1.0编码=UTF-8&GT?;
<结构>
  <启动>
    < supportedRuntime版本=v4.0.30319的SKU =NETFramework,版本= V4.0,外形=客户/>
    < supportedRuntime版本=V2.0.50727/>
  < /启动>
< /结构>
 

解决方案

通常情况下,没有 - 这将是相同的。

默认情况下,CLR 4运行时会加载CLR 2运行时执行你的CLR 2 code基地。在CLR 4强制执行需要设置useLegacyV2RuntimeActivationPolicy在你的App.config。

如果您添加标记,然后将在CLR的V4运行。在一般情况下,性能可能是非常相似的,但它可能与新的运行时略有不同,由于改变了JIT和核心运行时。有没有保证CLR 4会更快 - 这可能是有时慢,但在一般情况下,我期望的性能非常接近两个运行时在

Unity 热更新 HybridCLR 对接到项目中

如果您遇到性能问题,分析应用程序。改变运行时不会解决性能问题。剖析你的应用程序,同时在两个运行将是唯一的方式知道如果它使你有差别,但是。

Will a .NET program compiled for CLR 2.0 run faster if running unden CLR 4.0?

app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0.30319" sku=".NETFramework,Version=v4.0,Profile=Client" />
    <supportedRuntime version="v2.0.50727"/>
  </startup>
</configuration>

解决方案

Typically, no - it will be identical.

By default, the CLR 4 runtime will load the CLR 2 runtime to execute your CLR 2 code base. Forcing execution under CLR 4 requires setting useLegacyV2RuntimeActivationPolicy in your app.Config.

If you add that flag, then it will run in v4 of the CLR. In general, the performance is likely to be very similar, but it may differ slightly with the new runtime, due to changes in the JIT and core runtime. There is no guarantee that CLR 4 will be faster - it may be slower at times, though in general, I would expect the performance to be very close under both runtimes.

If you're having performance issues, profile your application. Changing the runtime will not fix a performance issue. Profiling your application while running under both will be the only way to know if it makes a difference for you, however.

阅读全文

相关推荐

最新文章