My C++ executable runs way faster outside the Visu

2019-06-24 19:55发布

I build a C++ application that does some number crunching. I'm running in Visual Studio 2008 PRO SP1, in release mode, Windows 7 64 bit. If I run it inside the IDE, the application takes 4 minutes, if I run the same executable from windows explorer it takes 6 seconds! I have no clue. I have checked that this does not depend on the processor and operating system. I don't think I have strange VS plugins that are doing something in the background.

Any hints? Thank you in advance!

Marco

2条回答
Explosion°爆炸
2楼-- · 2019-06-24 20:03

As Cody mentioned, one option is to simply not debug. But if you want to speed up your debugging sessions, here are a few things I've found can make a huge difference:

  1. Remove debugging print statements that are no longer necessary. If you see your log filling up with text, that is likely slowing you down significantly.
  2. Remove breakpoints (Ctrl+Shift+F5). A couple times I've noticed a huge drop in performance, and it turned out to be due to a breakpoint with a condition that was never met.
查看更多
The star\"
3楼-- · 2019-06-24 20:17

Presumably, the slow down is caused by the debugger being attached when you are starting the application in Visual Studio. This is the case even when you've built the program in "Release" mode.

To confirm that this is indeed the source of your problem, try running your application without the debugger, using the "Start Without Debugging" command or Ctrl+F5.

   Start Without Debugging

It's worth nothing that in C++ specifically, when you start without debugging, your program won't use the Windows debug heap. With the debugger attached, it will.

查看更多
登录 后发表回答