C#:调试与性能版 [英] C#: Debug vs. Release performance

查看:178
本文介绍了C#:调试与性能版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了以下内容:

调试与发布在IDE中,当您编译code在Visual Studio设置使得几乎没有差别性能...生成code几乎是一样的。 C#编译器并没有真正做任何优化。 C#编译器只是吐出IL ......并在运行时,它是做所有优化JITer。该JITer确实有一个调试/发布模式,这使得性能的巨大差异。但是,这并不关你是否运行调试按键或释放你的项目配置,即键关闭调试器是否连接。

"Debug vs. Release setting in the IDE when you compile your code in Visual Studio makes almost no difference to performance… the generated code is almost the same. The C# compiler doesn’t really do any optimization. The C# compiler just spits out IL… and at the runtime it’s the JITer that does all the optimization. The JITer does have a Debug/Release mode and that makes a huge difference to performance. But that doesn’t key off whether you run the Debug or Release configuration of your project, that keys off whether a debugger is attached."

来源是这里和播客<一href=\"http://go2.word$p$pss.com/?id=725X1342&site=andrewmyhre.word$p$pss.com&url=http%3A%2F%2Fwww.microsoft.com%2Fdownloads%2Fdetails.aspx%3FFamilyId%3DB11AD912-4158-44CC-A771-A5E044F7E3BB%26displaylang%3Den\">here.

有人能告诉我到微软的文章,实际上可以证明这一点?

Can someone direct me to a Microsoft article that can actually prove this?

谷歌搜索的 C#调试VS释放性能的大多是返回结果说的调试有很多性能损失版本进行了优化的和不部署调试到生产的。

Googling "C# debug vs release performance" mostly returns results saying "Debug has a lot of performance hit", "release is optimized", and "don't deploy debug to production".

推荐答案

部分正确。在调试模式中,编译器发出的所有变量调试符号和编译code原样。在释放模式一些优化包括:

Partially true. In debug mode the compiler emits debug symbols for all variables and compiles the code as is. In release mode some optimizations are included:


  • 未使用的变量没有得到根本编译

  • 某些循环变量是由编译器取出循环的,如果他们被证明是不变量

  • 在#调试指令写入code未包含等等。

剩下的就到JIT。

编辑:优化全部列表<一个href=\"http://blogs.msdn.com/ericlippert/archive/2009/06/11/what-does-the-optimize-switch-do.aspx\">here 埃里克利珀礼貌

Full list of optimizations here courtesy of Eric Lippert

这篇关于C#:调试与性能版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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