CLR 2.0 VS 4.0的性能? [英] CLR 2.0 vs 4.0 performance?

查看:213
本文介绍了CLR 2.0 VS 4.0的性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将在运行一个.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强制执行需要设置<一个href="http://msdn.microsoft.com/en-us/library/bbx34a2h.aspx"><$c$c>useLegacyV2RuntimeActivationPolicy在你的App.config。

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

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

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.

这篇关于CLR 2.0 VS 4.0的性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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