C++定义“更好” VS 中的发布模式构建

发布于 2024-08-25 14:46:31 字数 635 浏览 8 评论 0原文

我目前使用以下预处理器定义和各种优化设置:

  • WIN32_LEAN_AND_MEAN
  • VC_EXTRALEAN
  • NOMINMAX
  • _CRT_SECURE_NO_WARNINGS
  • _SCL_SECURE_NO_WARNINGS
  • _SECURE_SCL=0
  • _HAS_ITERATOR_DEBUGGING=0

我的问题是 SOers 还使用、添加、定义哪些其他东西来获得发布模式< /strong> 从 VS C++ (2008,2010) 构建以获得尽可能高的性能?

顺便说一句,我尝试过 PGO 等,它确实有一点帮助,但没有与 GCC 同等的,而且我没有使用流,我所说的 C++ 它更像 C,但使用模板和 STL 算法等等。

就目前情况而言,与 GCC 在使用 02 运行 Linux(2.6+ 内核)的等效 x86 机器上生成的代码相比,非常简单的代码段在性能方面显得苍白无力。

旁注: 我相信很多问题都与 MS 提供的 STL 版本 (Dinkum) 直接相关。请人们详细说明使用 STLPort 等与 VS C++ 的经验。

I currently use the following preprocessor defines, and various optimization settings:

  • WIN32_LEAN_AND_MEAN
  • VC_EXTRALEAN
  • NOMINMAX
  • _CRT_SECURE_NO_WARNINGS
  • _SCL_SECURE_NO_WARNINGS
  • _SECURE_SCL=0
  • _HAS_ITERATOR_DEBUGGING=0

My question is what other things do fellow SOers use, add, define, in order to get a Release Mode build from VS C++ (2008,2010) to be as performant as possible?

btw, I've tried PGO etc, it does help a bit but nothing that comes to parity with GCC, also I'm not using streams, the C++ i'm talking about its more like C but making use of templates and STL algorithms etc.

As it stands now very simple code segments pale in comparison wrt performance when compared to what GCC produces on say an equivalent x86 machine running linux (2.6+ kernel) using 02.

Side-Note: I believe a lot of the issues relate directly to the STL version (Dinkum) provided by MS. Could people please elaborate on experiences using STLPort etc with VS C++.

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

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

发布评论

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

评论(1

GRAY°灰色天空 2024-09-01 14:46:31

我不明白包含:

_CRT_SECURE_NO_WARNINGS
_SCL_SECURE_NO_WARNINGS

..如何为您提供更好或更高性能的构建。您所做的就是禁用有关 MS CRT 已弃用功能的警告。如果您这样做是因为您知道自己在做什么并且需要与平台无关的代码,否则我会重新考虑。

更新:此外,编译器只能做这么多。我敢打赌,如果您检测并修复现有的热点,而不是试图从编译和链接阶段寻求微小的百分比(如果是的话)收益,您将获得更高性能的代码。

UPDATE2:根据MSDN. WIN32_LEAN_AND_MEAN VC_EXTRALEAN(可能还有 NOMINMAX,尽管性能不是禁用此功能的主要原因)可能会给您带来一些性能提升,尽管其余的都具有可疑的价值。您应该青睐正确的快速代码,而不是(也许 - 我强调也许)稍快但更容易出现风险的代码。

I don't see how the inclusion of:

_CRT_SECURE_NO_WARNINGS
_SCL_SECURE_NO_WARNINGS

..gives you a better or more performant build. All you are doing is disabling the warnings about the MS CRT deprecated functions. If you are doing this because you know what you are doing and require platform agnostic code fine, otherwise I would reconsider.

UPDATE: Furthermore the compiler can only do so much. I'd wager you would get more performant code if you instrumented and fixed your existing hotspots rather than trying to eek tiny percentage (if that) gains from the compiling and linking phase.

UPDATE2: _HAS_ITERATOR_DEBUGGING cannot be used when compiling release builds anyway according to the MSDN. WIN32_LEAN_AND_MEAN VC_EXTRALEAN (and probably NOMINMAX although performance isn't the chief reason to disable this) might give you some performance boost although all the rest have dubious value. You should favour correct fast code over (maybe - and I stress maybe) slightly faster but more risk prone code.

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