在什么级别C#编译器或JIT优化应用程序代码? [英] At what level C# compiler or JIT optimize the application code?

查看:233
本文介绍了在什么级别C#编译器或JIT优化应用程序代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道这个信息,以减少我的代码大小,所以我不会浪费我的时间优化的事情将由编译器或JIT。



例如:



如果我们假设编译器内联对属性的get函数的调用,因此我不必将返回值保存在局部变量中,以避免函数调用。 / p>

我想推荐一个描述发生了什么的好参考。

解决方案

您可以查看这些文章:



JIT优化 - (Sasha Goldshtein - CodeProject)

Jit优化:内联I(David Notario)

Jit优化:内联II(David Notario)



老实说,你不应该担心太多的微观细节水平。让编译器/ JIT'er为你担心这一点,它比在几乎所有情况下都更好。不要挂断过早优化。专注于让你的代码工作,然后担心以后的优化如果(a)它运行不够快,(b)你有'大小'问题。


I want to know this info to reduce my code size so I will not waste my time optimize things that will be done by compiler or JIT.

for example:

if we assume the compiler inline the call to the get function of a property so I do not have to save the return value in a local variable to avoid function call.

I want to recommend a good reference that describes what is going on?

解决方案

You may want to take a look at these articles:

JIT Optimizations - (Sasha Goldshtein - CodeProject)
Jit Optimizations: Inlining I (David Notario)
Jit Optimizations: Inlining II (David Notario)

To be honest you shouldn't be worrying too much about this level of micro-detail. Let the compiler/JIT'er worry about this for you, it's better at it than you are in almost all cases. Don't get hung up on Premature Optimisation. Focus on getting your code working, then worry about optimisations later on if (a) it doesn't run fast enough, (b) you have 'size' issues.

这篇关于在什么级别C#编译器或JIT优化应用程序代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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