问题描述
我想知道这些信息以减少我的代码大小,这样我就不会浪费我的时间来优化将由编译器或 JIT 完成的事情.
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.
例如:
如果我们假设编译器将调用内联到属性的 get 函数,那么我不必将返回值保存在局部变量中以避免函数调用.
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 优化 - (Sasha Goldshtein - CodeProject)
Jit 优化:内联 I (David Notario)
Jit 优化:内联 II (David Notario)
老实说,您不应该过多担心这种级别的微观细节.让编译器/JIT'er 为您担心这个问题,在几乎所有情况下它都比您做得更好.不要沉迷于过早优化.专注于让您的代码正常工作,然后在 (a) 运行速度不够快、(b) 您遇到大小"问题时担心以后的优化.
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 在什么级别优化应用程序代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!