建立在值为anycpu VS x64平台在64位计算机上的C#应用​​程序的性能机上、值为、性能、程序

2023-09-03 02:21:09 作者:安生

我要部署一个64位计算机上的C#应用​​程序,虽然有轻微的可能性,它也可以被部署在32位计算机上。我应该建立针对x86和x64平台两个独立的可执行文件或者我应该去为一个单一的可执行内置定位值为anycpu'平台(在项目属性的编译选项中指定。会不会有一个C#组件内置定位之间的任何服务表现差'值为anycpu部署在64位​​计算机上VS内置相同的程序集专门针对64平台?

I have to deploy a C# application on a 64 bit machine though there is a slight probability that it could also be deployed on a 32 bit machine. Should I build two separate executables targeting x86 and x64 platform or should I go for a single executable built targeting 'AnyCPU' platform (specified in the project property's Build option'. Would there be any performace difference between a C# assembly built targeting 'AnyCPU' is deployed on a 64 bit machine vs the same assembly built targeting specifically 'x64' platform ?

推荐答案

没有,存在值为anycpu应用程序在64位Windows上运行,并在其上​​运行在x64应用程序之间的性能没有区别。唯一的标志,变化是在编译的程序集的标题一些标志和CLR使用它只是决定是否要使用x86或x64,没有别的

No, there is no difference in performance between AnyCPU application running on a 64-bit Windows and an x64 application running on it. The only thing that flag changes are some flags in the header of the compiled assembly and the CLR uses it only to decide whether to use x86 or x64, nothing else

如果你问是否有在64位Windows和64位(或值为anycpu)上运行的x86应用程序之间的差异,那么答案是肯定的。两者之间的区别是:

If you were asking whether there is a difference between x86 application running on a 64-bit Windows and an x64 (or AnyCPU), then the answer would be yes. The differences between the two are:

在64位显然使用两倍的一样大,32位,这意味着更大的内存消耗引用,但它也意味着您可以使用更多的内存 在64位可以使用更多的寄存器,只适用于CPU的64位模式 在64位JIT是从32位JIT不同,它具有不同的优化,例如:64位JIT有时使用的尾调用优化的即使使用尾巴,你不用特意提出要求。指令(其中例如C#中不可能发生) 64-bit obviously uses references that are twice as big as 32-bit, which means larger memory consumption, but it also means you can use more memory 64-bit can use more registers that are available only in the 64-bit mode of CPUs 64-bit JIT is different from 32-bit JIT, it has different set of optimizations: for example 64-bit JIT sometimes uses the tail call optimization even if you don't specifically request it using the tail. instruction (which for example C# never does)