2

I'm new to visual studio. I created a console application in vs2017 to test the performance of a library, the code is very simple, something like

start stopwatch
insert a bunch of elements to a list. 
stop stopwatch
print out the time used

The strange thing is that when I run it within visual studio 2017, the time used is drastically smaller when running under "start without debug", i.e control+f5, comparing to "start with debug". I wonder what is causing the difference and which number should I use as a benchmark once I deployed this console app to cloud.

Thanks.

checai
  • 836
  • 4
  • 11
  • 17
  • 2
    You will want to analyze performance in Release mode without a Debugger as that's how your program will run in production. See https://stackoverflow.com/questions/1047218/benchmarking-small-code-samples-in-c-can-this-implementation-be-improved. There's also https://msdn.microsoft.com/en-us/library/bb385749.aspx for a more general approach to performance analysis – Freggar Jun 13 '18 at 07:18

1 Answers1

0

Running on a development/developer machine cannot be considered as a benchmark for performance measurement. The best practice is to have a performance test[preferably automated] which is executed regularly on a machine which is as close as possible to your production environment. The test should capture the time taken for the use cases that you are interested in bench marking.

Prashanth R
  • 224
  • 5
  • 14