简体   繁体   English

在64位计算机上基于AnyCPU vs x64平台构建的C#应用​​程序的性能

[英]Performance of a C# application built on AnyCPU vs x64 platform on a 64 bit machine

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. 我必须在64位计算机上部署C#应用程序,尽管它也可能部署在32位计算机上。 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 ? 我应该构建两个针对x86和x64平台的独立可执行文件,还是应该针对“AnyCPU”平台(在项目属性的“构建”选项中指定)构建单个可执行文件。在C#程序集构建的目标“AnyCPU”之间是否存在任何性能差异?部署在64位计算机上与相同的程序集部署专门针对'x64'平台?

No, there is no difference in performance between AnyCPU application running on a 64-bit Windows and an x64 application running on it. 不,在64位Windows上运行的AnyCPU应用程序与在其上运行的x64应用程序之间的性能没有差异。 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 标志更改的唯一内容是编译程序集的标头中的一些标志,CLR仅使用它来决定是使用x86还是x64,没有别的

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. 如果您在询问在64位Windows上运行的x86应用程序与x64(或AnyCPU)之间是否存在差异,那么答案是肯定的。 The differences between the two are: 两者之间的差异是:

  • 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位显然使用的引用是32位的两倍,这意味着更大的内存消耗,但它也意味着你可以使用更多的内存
  • 64-bit can use more registers that are available only in the 64-bit mode of CPUs 64位可以使用更多仅在64位CPU模式下可用的寄存器
  • 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. 64位JIT与32位JIT不同,它具有不同的优化集:例如64位JIT有时会使用尾调用优化,即使您没有使用tail.特别请求它tail. instruction (which for example C# never does) 指令(例如C#从不这样做)

As a side note to the above answer. 作为上述答案的旁注。 There can be issues with using P/Invoke or DotNetInterop into x86 DLL's on an x64 OS using AnyCPU. 使用AnyCPU在x64操作系统上使用P / InvokeDotNetInterop进入x86 DLL 可能会出现问题。 In the case where no 64-bit version of the DLL is available, it may be necessary to compile x86 rather than AnyCPU as the OS will try to load the 64-bit version...and fail. 在没有64位版本的DLL可用的情况下,可能需要编译x86而不是AnyCPU,因为操作系统将尝试加载64位版本......并且失败。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 64位计算机上AnyCPU与x64平台之间的性能差异 - Performance difference between AnyCPU vs x64 platform on a 64 bit machine 如何强制程序集作为针对AnyCPU平台构建的x64位运行? - How to Force an assembly to run as x64 bit which was built against AnyCPU platform? 在 .NET C# 应用程序 (WinForms) 中使用 ActiViz 时如何定位 x64(64 位)平台 - How to target x64 (64 bit) platform while using ActiViz in a .NET C# application (WinForms) 用于C#应用程序的AnyCPU / x86 / x64及其C ++ / CLI依赖性 - AnyCPU/x86/x64 for C# application and it's C++/CLI dependency 强制C#app编译为x64而不是AnyCpu - Force C# app to compile as x64 instead of AnyCpu c#visual studio使用目标anycpu构建exe,但在调用进程平台(x86 / x64)上确定其平台(x86 / x64) - c# visual studio build exe with target anycpu but that determines its platform(x86/x64) on the calling process platform(x86/x64) 除非为 x86 平台构建,否则不安全的 c# 代码会导致 64 位平台上的堆损坏 - unsafe c# code causes heap corruption on 64 bit platform unless built for x86 platform p /从x64机器上运行的C#程序调用32位dll - p/invoke a 32-bit dll from a C# program running on an x64 machine System.Web生成错误,将C#项目从AnyCPU切换到x64 - Build error with System.Web switching a C# project over from AnyCPU to x64 如何从 c# 中的 x86 应用程序启动 x64 位应用程序 - How to start x64 bit application from x86 application in c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM