What is best way to measure the time cycles for a C# function?
<p>Really, I'm looking for a good function that measure the time cycles accurately for a given C# function under Windows operating system. I tried these functions, but they both do not get accurate measure:</p>

<pre><code>DateTime StartTime = DateTime.Now;      
TimeSpan ts = DateTime.Now.Subtract(StartTime);
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
//code to be measured
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed; 
</code></pre>

<p>Really, each time I call them, they give me different time for the same function</p>

<p>Please, if anyone know better way to measure time consuming accurately, please help me and thanks alot alot</p>
