.NET 4.0比早期版本更慢,是真的吗?版本、NET

2023-09-03 13:50:26 作者:高大上的昵称

可能重复:   Are .NET 4.0运行时慢于.NET 2.0运行时?

您好所有,

我们正计划迁移到.NET框架4.0不久的某个时候... 我不记得在基准或链接,但最近,我读到的时候相比,它的predecessors最新的框架是在性能上有点慢。

We are planning to move to .NET framework 4.0 sometime soon... I don't remember the refernce or link, but recently, I read about the latest framework being a little slow in performance when compared to its predecessors.

是这样吗?曾有人做过测试,还是有一些有效的论据来支持这一点?

Is that true? has anybody done any tests or have some valid arguments to support this?

推荐答案

这是不可能做出关于对.NET 4.0早期版本相比性能一般性发言。微软正在不断完善的框架,从而使性能提升。无论是在首创置业业绩的改善,在运行时本身。例如,冷启动时间显着改善和GC的性能都在3.5SP1和在4.0的提高。在另一方面,这个框架变得越来越大,这意味着更多的code。更多code意味着更多的页面缺失,意味着性能下降。

It is impossible to make a general statement about the performance of .NET 4.0 compared to earlier versions. Microsoft is constantly improving the framework, thus making performance improvements. Performance is improved both in the BCL as in the runtime itself. For instance, cold startup time is improved dramatically and the performance of the GC has improved both in 3.5sp1 and in 4.0. On the other hand, the framework is getting bigger and this means more code. More code means more page misses, means slower performance.

在另一方面,.NET 4.0引入了新的技术,可以大大提高您的code(如TPL)的性能。而且不要忘了,新的技术将被引入是提高开发人员的表现,这是所有的最重要的部分。

On the other hand, .NET 4.0 introduces new techniques that that can drastically improve the performance of your code (such as the TPL). And don’t forget that new techniques will be introduced that improve the developer performance, which is the most important part of all.

所以,不要被情绪和小道消息的影响。即使.NET 4.0的速度较慢,这不应该担心你。你应该基准,如果框架的一部分是不够快你的要求。如果不是,你可以随时回到这里的SO并要求特定的方案如何能够得到改善。它几乎总是可能避开它。

So don't get influenced by sentiment and gossip. Even if .NET 4.0 is slower, this shouldn't worry you. You should benchmark if that part of the framework is fast enough for your requirements. If it isn't, you can always come back here at SO and ask how that particular scenario can be improved. It is almost always possible to get around it.