C# 调试与发布
Windows 服务在调试版本和发布版本之间可以获得多少性能增益(如果有)?为什么?
How much performance gain (if any) can a windows service gain between a debug build and release build and why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于托管代码,除非您有很多东西有条件地编译为 DEBUG 构建,否则应该没有什么区别 - IL 应该几乎相同。无论是否在调试器下运行,抖动都会产生不同的结果 - IL 的编译不会受到太大影响。
编译为 IL 时,
/optimize
会执行一些操作,但它们并不是特别激进。其中一些 IL 优化可能会由抖动优化来处理,即使它们没有在 IL 中进行优化(例如删除 nop)。请参阅 Eric Lippert 的文章 http://blogs.msdn.com/ericlippert/archive/2009/06/11/what-does-the-optimize-switch-do.aspx 了解详细信息:
阅读 Eric 的文章,了解有关
/optimize
在 IL 生成中确实有不同作用的信息。For managed code, unless you have a lot of stuff conditionally compiled in for DEBUG builds there should be little difference - the IL should be pretty much the same. The Jitter generates differently when run under the debugger or not - the compilation to IL isn't affected much.
There are some things the
/optimize
does when compiling to IL, but they aren't particularly aggressive. And some of those IL optimizations will probably be handled by the jitter optimizations, even if they aren't optimized in the IL (like the removal of nops).See Eric Lippert's article http://blogs.msdn.com/ericlippert/archive/2009/06/11/what-does-the-optimize-switch-do.aspx for details:
Read Eric's article for information about
/optimize
does do differently in IL generation.好吧,虽然这个问题是重复的,但我觉得原始问题中的一些更好的答案位于最底部。就我个人而言,我见过调试模式和发布模式之间存在明显差异的情况。 (示例:属性性能,访问属性之间存在 2 倍的差异调试和发布模式)。这种差异是否会出现在实际的软件(而不是类似基准测试的程序)中是有争议的,但我已经在我开发的一个产品中看到了这种情况的发生。
来自尼尔对原始问题的回答,来自 msdn 社交:
Well, though the question is a duplicate, I feel that some of the better answers in the original question are at the very bottom. Personally I have seen situations where there is an appreciable difference between debug and release modes. (Example : Property performance, where there was a 2x difference between accessing properties in debug and release mode). Whether this difference would be present in an actual software(instead of benchmark like program) is debatable, but I have seen it happen in one product I worked on.
From Neil's answer on the original question, from msdn social: