I want to measure the execution of a piece of code and I\'m wondering what the best method to do this is?
Option 1:
DateTime StartTime = DateTime.Now
I have a little class to do this sort of thing ad hoc. It uses the stopwatch class - c# micro perfomance testing.
eg.
var tester = new PerformanceTester(() => SomeMethod());
tester.MeasureExecTime(1000);
Console.Writeline(string.Format("Executed in {0} milliseconds", tester.AverageTime.TotalMilliseconds));