在.NET中,将空的方法调用进行优化呢? [英] In .NET, will empty method calls be optimized out?

查看:120
本文介绍了在.NET中,将空的方法调用进行优化呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于空的方法体,将JIT优化了电话(我知道C#编译器不会)。我将如何去寻找呢?我应该使用什么工具,在哪里我可以找?

Given an empty method body, will the JIT optimize out the call (I know the C# compiler won't). How would I go about finding out? What tools should I be using and where should I be looking?

因为我相信它会被要求,为空方法的原因是preprocessor指令。

Since I'm sure it'll be asked, the reason for the empty method is a preprocessor directive.

推荐答案

这章有相当好的治疗JIT的优化,做好在页面上搜索的方法是空的,它的一半左右一路下跌的文章 -

This chap has quite a good treatment of JIT optimisations, do a search on the page for 'method is empty', it's about half way down the article -

HTTP://www.$c$cproject.com/KB/ DOTNET / JITOptimizations.aspx

显然,空的方法都得到了优化,通过内联的是实际上没有code。

Apparently empty methods do get optimised out through inlining what is effectively no code.

@克里斯:我的确意识到了二进制的,这些方法还是将一部分,而这些是JIT的优化:-)。在一个半相关的说明,在Scott Hanselman曾在发布版本调用堆栈上内联一个相当有趣的文章:

@Chris: I do realise the that the methods will still be part of the binary and that these are JIT optimisations :-). On a semi-related note, Scott Hanselman had quite an interesting article on inlining in Release build call stacks:

<一个href="http://www.hanselman.com/blog/ReleaseISNOTDebug64bitOptimizationsAndCMethodInliningInReleaseBuildCallStacks.aspx" rel="nofollow">http://www.hanselman.com/blog/ReleaseISNOTDebug64bitOptimizationsAndCMethodInliningInReleaseBuildCallStacks.aspx

这篇关于在.NET中,将空的方法调用进行优化呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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