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 generally use StopWatch for this kind of situation.
StopWatch
From MSDN page:
StopWatch Provides a set of methods and properties that you can use to accurately measure elapsed time.
Provides a set of methods and properties that you can use to accurately measure elapsed time.
In the following post I use it to compare the execution time of LINQ vs PLINQ:
Parallel LINQ (PLINQ) with Visual Studio 2010