Why does program run faster in Visual Studio than compiled exe

I have a C# console program, developed in Visual Studio Premium 2013. When I start the program in Visual Studio - either with or without debugging - it runs significantly faster than if I run the compiled EXE. I have tried both the "Debug" and "Release" compiled EXE's.

The difference is huge - 5 seconds when running in VS against 50+ seconds running as an EXE. That is the time for 1 "job", eventually, this application needs to process around 2000+ jobs!

In both cases, I am running from the same computer and using the same config file.

How can there be such a massive difference and why would running within VS be faster?! I must be missing something significant!?
Gordon SaxbySenior Web DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
are you accessing the same resources (files, databases, ...)?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gordon SaxbySenior Web DeveloperAuthor Commented:
Yes, it is connecting to one server to extract data, it then processes that data and writes it to another server. The connections are all defined in its config file ... so both instances should be doing exactly the same thing. I have checked that the config file is correct.

It seems like the connections to the other servers are taking the most time, when running the exe - but is hardly noticeable when running in Visual Studio.
Éric MoreauSenior .Net ConsultantCommented:
strange. I am clueless!
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

käµfm³d 👽Commented:
Run a profiler on your code to see where the most time is being spent in the code itself. Then, if something environmental jumps out, you can investigate that.
Hi ascendinternet,

probably you run the exe with different command line options or in a different working directory when starting from within VS - check your project's Debug settings.

Gordon SaxbySenior Web DeveloperAuthor Commented:
I have been using "cmder" to run the program, but today noticed that the timings for the same set of test data varied. I then ran the program against the same data, using the normal "cmd" DOS window.

The cms window is always faster than the cmder window, however, the times do vary and it now looks like it is a network / source system (Microsoft CMS) issue.

Running the program using "Start without Debugging" in Visual Studio is still the fastest (!?), but running the exe now appears to be nearly as fast. As this does not appear to be a Visual Studio / coding issue, I will close this question.

Thanks for all the suggestions.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.