1

I work with C++ integer programming routines in terms of developing faster specialized methods for difficult NP-Hard problems. I came across an earlier question that dealt more with getting different results when an application is launched from within an IDE (Visual Studio) versus running the built application from the command line without opening the IDE at all.

Differences between running an executable with Visual Studio debugger vs without debugger

This question is not about different results, but more about whether each option (running from within IDE vs running executable standalone) has any impact on computational time and performance. In my line of work, it is important to show that any specialized algorithm that we develop does much better in terms of computational time as compared to solving the integer program directly using a generic off the shelf solver such as CPLEX. Testing both these options (our specialized algorithm vs CPLEX directly) requires generating a linear/integer programming model from using CPLEX routines and libraries embedded within a C++ file.

Then, each setting is built from within Visual Studio (F7) and run (F5). Note that F7 itself generates the executable file.

To give each method (our specialized algorithm or CPLEX directly) the best chance to run with as fast computational time as possible, is it suggested to launch the application by pressing F5 within the IDE (Visual Studio, in this case), or it is better to run the application (generated by build F7) as an .exe without even opening the IDE? Assume that the working directory and intermediate files that are needed are accessed from the same folder for both options (IDE vs standalone .exe).

In other words, does IDE launch differ in any significant way from running the .exe directly so as to have an impact on computational times of the application?

Tryer
  • 3,580
  • 1
  • 26
  • 49
  • 1
    The IDE will run your program as a "stand alone executable". It should create the process just like a shell/command-line or "explorer"-interface would. – Some programmer dude Jan 26 '18 at 17:23
  • 1
    If you launch it _without_ the debugger it doesn't make any difference, it's exactly the same as running it from the command line. – Jabberwocky Jan 26 '18 at 17:23
  • 1
    As for your problem, are you sure that you *run* your program, and not *debug* it? Because running inside a debugger might lead to different behavior when it comes to initialization of otherwise uninitialized variables. You should check that you initialize variables properly before you use them. – Some programmer dude Jan 26 '18 at 17:23
  • 1
    Beware: F5 runs it _with_ the debugger, Ctrl+F5 runs it _without_ the debugger. – Jabberwocky Jan 26 '18 at 17:24
  • @Someprogrammerdude, MichaelWalz I do launch it from within IDE and the application runs, but I observe that I can no longer close the IDE. I was running F5 thus far in release mode. But not Ctrl+F5. Would that make a difference? IN any case, thanks, will ensure I run Ctrl+F5 from here on. – Tryer Jan 26 '18 at 17:26
  • 1
    F5 runs it with the debugger, Ctrl+F5 runs it without the debugger. This is independent of the "Release"/"Debug" version. Even if you run the "Release" version with F5, it will run under the debugger. – Jabberwocky Jan 26 '18 at 17:29
  • If you experience any different behaviour (except timing differences) between the debug and release version, that means most likely that your program has stumbled upon undefined behaviour. – Jabberwocky Jan 26 '18 at 17:32
  • Thus far, I ensure my Debug and Release versions get the same result. I was under the impression that you cannot have breakpoints in release modes. But I have just figured out that breakpoints, etc., are disabled if you run Ctrl + F5. – Tryer Jan 26 '18 at 17:33
  • BTW: you _can_ debug "release version" programs and you even can set breakpoints if you're lucky. This is very useful for debugging crashes that happen un Release mode but not in Debug mode. – Jabberwocky Jan 26 '18 at 17:35
  • Yes, running with Ctrl+F5 just runs the program without any debugger and therefore the breakpoints won't get hit of course. – Jabberwocky Jan 26 '18 at 17:36
  • @MichaelWalz Thanks for your hints. One last Question. If I set "Release" Mode and do Ctrl + F5 from within IDE, I will get best possible computing times, yes? This is then no different from a relase time build F7 (within IDE) and then running the .exe as a standalone without even opening the IDE. – Tryer Jan 26 '18 at 17:44
  • 1
    Exactly. You are right – Jabberwocky Jan 26 '18 at 17:46
  • 1
    *"If I set "Release" Mode and do Ctrl + F5 from within IDE, I will get best possible computing times, yes?"* - There's no magic behind it. What the IDE calls "Release" or "Release mode" is just a **predefined set of compiler/linker options**, i.e. flags that you would otherwise pass on the command line to `cl.exe` or to `link.exe`. One of those predefined options is the `/O2` flag. The IDE has it under "Configuration properties" / "C/C++" / "Optimization". Note that in real projects, you will usually modify some of those options or even use your own configuration sets. – Christian Hackl Jan 26 '18 at 17:55
  • @ChristianHackl Yes. Thanks. My worry was whether having the IDE open (Release + Ctrl F5) will somehow cause the application to slow down as compared to Release build F7 and then launching the .exe separately. – Tryer Jan 26 '18 at 17:57
  • 1
    If timing is critical, then I would try to run on as empty a machine as possible, as other processes will eat machine resources. That includes the VS IDE. There will be a lot of other stuff going on inside Windows anyway, but doing your best to minimise other stuff should improve consistency. So I would just run the .exe versions standalone. – TimChippingtonDerrick Jan 27 '18 at 05:11
  • @MichaelWalz https://stackoverflow.com/questions/13841902/release-build-in-visual-studio-ctrlf5-10x-slower-than-from-outside-vs seems to be giving some contradictory info on this question. Could I request your thoughts on this? Should one worry about _NO_DEBUG_HEAP settings, etc.? – Tryer Jan 27 '18 at 05:37

1 Answers1

1

In Visual Studio, your program is run as a standalone process. Before starting you can choose Debug or Release version to run. The Release version has optimizations enabled.

When running within the IDE, VS is monitoring your application, so there might be some kind of overhead. You need to measure on your specific machine to find out how much.

With ctrl-f5 you can run your application outside the IDE.

Robert Andrzejuk
  • 5,076
  • 2
  • 22
  • 31