我可以在.NET中避免JIT吗? [英] Can I avoid JIT in .NET?

查看:77
本文介绍了我可以在.NET中避免JIT吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我的代码是否总是要在特定处理器上运行,并且如果我在安装过程中有此信息-是否有机会避免使用JIT?

Say if my code is always going to be run on a particular processor and if I have this information during installation - is there a chance I can avoid JIT?

推荐答案

如果在安装时具有CPU信息,则不必避免JIT。

You don't have to avoid JIT if you have CPU information at installation.

如果使用/ platform:[x86 / x64 / IA64]开关编译模块,则编译器会将此信息包含在生成的PE文件中,以便CLR将将代码JIT到适当的CPU本机代码中,并针对该CPU体系结构优化代码。

If you compile your modules using the /platform:[x86/x64/IA64] switch, the compiler will include this information in the resulting PE file so that the CLR will JIT the code into the appropriate CPU native code and optimize the code for that CPU architecture.

您可以使用 NGEN ,是的,但仅当您由于减少了工作集而希望改善应用程序的启动时运行该进程不会因为您避免了JITting。而且,您实际上需要比较NGEN文件和非NGEN文件的性能,以确保NGEN文件的速度更快。

You can use NGEN, yes but only if you want to improve the application's startup as a result of the reduced working set in the processes running not becuase you would have avoided JITting. And you need to actually compare the NGEN'd files' performance against that of the non-NGEN'd files' to make sure that the NGEN'd one is faster.

NGEN不能像JIT编译器那样对执行环境进行尽可能多的假设,因此会生成未优化的代码。

NGEN can't make as many assumptions about the execution environment as the JIT compiler can and therefore will produce unoptimized code.

例如:它为静态字段访问添加了间接方式因为静态字段的实际
地址仅在运行时才知道。

For example: it adds indirections for static field access because the actual address of the static fields is known only at run time.

这篇关于我可以在.NET中避免JIT吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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