<t>Stopwatch is designed for this purpose and is one of the best ways to measure time execution in .NET.<br/>
<br/>
var watch = System.Diagnostics.Stopwatch.StartNew();<br/>
// the code that you want to measure comes here<br/>
watch.Stop();<br/>
var elapsedMs = watch.ElapsedMilliseconds;<br/>
<br/>
```<br/>
<br/>
[**Do not** use DateTime](https://stackoverflow.com/questions/28637/is-datetime-now-the-best-way-to-measure-a-functions-performance) to measure time execution in .NET.<br/>
<br/>
If you want a real precise measurement of the execution of some code, you will have to use the performance counters that's built into the operating system. The [following answer](https://stackoverflow.com/questions/1409762/creating-a-perfmon-counter-to-record-an-average-per-call-c/1409833#1409833) contains a nice overview.</t>