简体   繁体   English

C ++优化问题

[英]C++ optimization question

I have some mid-large project that is actively using boost libraries and, hence, suffers in terms of Debug application performance (Visual Studio 2008). 我有一些正在使用boost库的中型项目,因此在调试应用程序性能方面受到了影响(Visual Studio 2008)。

Solution that I use right now means turning on function inlining even in Debug mode, which brings enough performance, but should definitely have some drawbacks. 我现在使用的解决方案意味着即使在调试模式下打开函数内联,这也带来了足够的性能,但肯定会有一些缺点。

Does anyone know what will I lose in terms of debugging capabilities if I force function inlining ( /Ob2 ) switch? 如果强制进行函数内联( /Ob2 )切换,有谁知道在调试功能方面我会失去什么?

Maybe someone have any other ideas about speeding up boost / other template libraries Debug performance? 也许有人对加速boost /其他模板库的调试性能有任何其他想法?

In my opinion, you should probably not be performance-testing your debug release. 在我看来,您可能应该对性能测试调试版本。

Save the debug release for unit testing so you can easily find problems but real testing (functionality and performance) should probably be on the release version. 保存调试版本以进行单元测试,以便您可以轻松找到问题,但实际测试(功能性能)可能应该在发布版本上。

That's what your customers will be running after all, right? 这毕竟是你的客户将要运行的,对吧?

I agree with the previous answers that you should not really care about the performance of your debug build in general. 我同意以前的答案,你一般不应该关心调试版本的性能。 The tests are there because we need them... 测试是因为我们需要它们......

However, I am a pragmatic programmer, and there is a reason I do not use a valgrinded application to run my tests: I don't want them to be too slow either, because the system becomes completely impractical at that point. 但是,我是一个务实的程序员,并且有一个原因我不使用一个valgrinded应用程序来运行我的测试:我也不希望它们太慢,因为系统在那时变得完全不切实际。

I don't see anything wrong with enabling inlining, sure the debugger might have some issues picking out the place in code which produced the code, but it doesn't modify the code itself. 我没有看到启用内联有任何问题,确保调试器可能在产生代码的代码中挑选出一些问题,但它不会修改代码本身。

I have also seen partial-debug builds. 我也看到了部分调试版本。 The idea is to turn off those debug features which really cripple the program (like iterator checking) so that performance remains acceptable for the task at hand. 我们的想法是关闭那些真正削弱程序的调试功能(比如迭代器检查),以便性能对于手头的任务仍然可以接受。 It could potentially help you here, if you figure which debug features slows you down. 如果您确定哪些调试功能会降低您的速度,它可能会对您有所帮助。 That being said I have never had performance issues with boost, but then I compile it with gcc and I don't know if inlining is preserved or not in debug. 话虽如此,我从未遇到过boost的性能问题,但后来我用gcc编译它,我不知道在调试中是否保留了内联。

I would suggest debugging the application built in Debug mode and using it when its built in Release mode (for performance tests, general usage etc.). 我建议调试在Debug模式下构建的应用程序,并在内置的Release模式下使用它(用于性能测试,一般用法等)。 That way you won't need to worry about losing anything while debugging. 这样你就不必担心在调试时丢失任何东西。

Anyway, turning on inlining of functions in Debug might confuse the debugger when you traverse the code and you encounter a function call to a function that was inlined. 无论如何,当您遍历代码并且遇到对内联函数的函数调用时,打开Debug中的函数内联可能会混淆调试器。 But i never tested that, so i'm not sure. 但我从未测试过,所以我不确定。

Use /Ob2 in both Debug and Release configurations. 在Debug和Release配置中使用/Ob2 So when you debug it, it would behave the same way as in release mode. 所以当你调试它时,它的行为方式与发布模式相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM