title: How we can measure cpu time for a method using PerformanceCounter?
body: <p>I want to measure cpu time for a method Not using StopWatch or Process but using the .NET profiler PerformanceCounter.</p>
  
  <p>I see that their is only method to calculate how much cpu is used by a process</p>
  
  <pre><code>PerformanceCounter cpuCounter = new PerformanceCounter("Process", "% Processor Time", ProcessName);
  CounterSample cs1 = cpuCounter.NextSample();
  </code></pre>
  
  <p>But i'm looking for all the time spent in the process using this API.</p>