将配置设置为发布或保留为调试

发布于 2024-11-26 09:43:24 字数 100 浏览 3 评论 0原文

在 Visual Studio 中,当您编译代码以将其安装在生产环境中时,是否将配置更改为“发布”?如果是这样,您是否发现了一些性能改进,或者是因为其他一些因素?您能分享一下这个因素吗?

In Visual Studio, when you compile your code to install it in production environment do you change the configuration to "release"? If you do, have you found some performance improvement or you do because some other factor? Can you share this factor?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

热鲨 2024-12-03 09:43:24

发布模式代码经过编译器优化,所有调试符号都被删除,项目状态信息被丢弃,等等,以便尽可能高效、轻松地运行它。将库的发布模式版本发布到生产环境始终是一个好主意。

然而,有一个技巧可以两全其美: http://www.hanselman.com/blog/PermaLink.aspx?guid=a40c0d4f-66d0-4704-94f6-0efda4a44465

Release mode code goes thru compiler optimizations, all debug symbols are removed, project state info is discarded and a lot more to run it as efficiently and lightly possible. t is always a good idea to publish the Release mode version of your library to production.

However, there is a trick to get best of both worlds: http://www.hanselman.com/blog/PermaLink.aspx?guid=a40c0d4f-66d0-4704-94f6-0efda4a44465

念﹏祤嫣 2024-12-03 09:43:24

将其更改为针对您部署的内容的发布。释放优化目标开关。所有其他因素都相同时,您的代码速度更快。改进程度取决于您的代码。

Release 还会关闭 DEBUG 和 TRACE 常量。两者都可能执行额外的代码,甚至创建您在生产环境中通常不需要的文件访问(写入日志)。

Change it to Release for what you deploy. Release target switches on optimization. All other factors equal your code is faster. The degree of improvement depends on your code.

Release also switches off the DEBUG and the TRACE constants. Both may execute additional code or even create file access (writing logs) that you typically don't want in a production environment.

﹉夏雨初晴づ 2024-12-03 09:43:24

当您将配置设置为“调试”时,编译器会生成大量额外信息,以便您在 Visual Studio 中单步调试代码。如果您正在制作一个库,或者任何真正的东西,并且您希望它成为生产版本,那么您不想发布调试版本。它会变得臃肿。另外,如果它不能优雅地处理崩溃(并不是说你一开始就应该有任何崩溃:P)。

具体来说,编译器不会像通常那样优化事物,因为它需要某些信息来返回给调试器。发布版本肯定会运行得更快,但性能并不总是有明显的提高。

When you have the configuration set to Debug, there is a lot of extra information generated by the compiler in order to allow you to step through your code in visual studio. If you are making a library, or anything really, and you want it to be production, you don't want to release the debug version. Its going to be bloated. Also, if it wont handle crashes as elegantly (not that you should have any in the first place :P).

Specifically, the compiler will not optimize things as well as it normally could since it needs certain information to give back to the debugger. The release version will certainly run faster, but its not always a noticeable increase in performance.

睫毛溺水了 2024-12-03 09:43:24

您通常会使用发布配置。调试版本通常是较大的文件,有时甚至更大;它们通常使用比释放配置更多的内存(因为它们填充变量/全局变量以调试内存管理等),并且释放的执行方式也不同,因为它们将未初始化的变量初始化为特定值(通常都是 \0,但我认为这是每个项目都可以定义的) )。

由于它们还包含调试信息,因此它可以允许最终用户更轻松地对可执行文件/库进行逆向工程,而您可能不希望他们能够做到这一点。

生产环境很可能还需要安装调试库,这会添加到您必须与应用程序打包的可重新分发文件中。

You would usually use Release configuration. Debug version are usually larger files, sometimes much larger; they usually use more memory than release configurations (as they pad variables/globals for debugging memory management etc), and also perform differently to release in that they initialise uninitialised variables to specific values (usually all \0, but that's definable per project I think).

As they also contain debug info, it could allow the end user to much more easily reverse engineer an executable/library, which you probably don't want them to be able to do.

The production environment would most likely also need the debug libraries installed, which adds to the re-distributable files you'd have to package with your app.

携余温的黄昏 2024-12-03 09:43:24

我们设置了构建服务器来为 QA 进行发布构建(并且我们发布了我们测试的内容)。

据我了解,在发布模式下生成的程序集是:

  • 更快更
  • 不包含调试信息。

有关更多详细信息,请查看以下内容:

We have our build server set up to do release builds for QA (and we ship what we test).

As I understand it, assemblies produced in release mode are:

  • faster
  • smaller
  • do not contain debug information.

For more detailed information, have a look at these:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文