I am solving some algorithm problems in c# and running them as a console application.
To check for the efficiency of the applications I would like to see what their run times are.
Currently I am printing the time at the start of a program and at the end and calculating the time difference ,but is there a way to reduce Observer’ effect ?
Some inbuilt tool/plugin that I am not aware of ?
You should use the
Stopwatchclass, which is specifically designed to do that.To avoid measuring the JIT time, you should also run each algorithm at least once before measuring anything so that the JIT has time to run.
When measuring the algorithms, you should run each one hundreds of times and take the average runtime.