Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the most appropriate performance counter type for measuring operation time?

Say I have a method Foo() and I want to measure the time in milliseconds it took to execute which type of Windows Performance Counter should I be using?

var stopwatch = new Stopwatch();
stopwatch.Start();
Foo();
stopwatch.Stop();
counter.RawValue = stopwatch.TotalMilliseonds;

Currently I'm using NumberOfItems64 but that persists the last value of the counter unless the new operation is performed. Is it desirable? Or should the counter go to zero as soon as the operation is done? Which counter type would you choose in this situation and why?

like image 487
Muhammad Hasan Khan Avatar asked Dec 10 '09 08:12

Muhammad Hasan Khan


People also ask

Which of the following are measured by performance counters?

Performance monitor Performance counters are bits of code that monitor, count, or measure events in software, which allow us to see patterns from a high-level view. They are registered with the operating system during installation of the software, allowing anyone with the proper permissions to view them.

What PerfMon counters should I monitor?

Anything consistently over 65% should be investigated and this might mean digging deeper into exactly what process is using the CPU (if it's not SQL Server) by using the "[Process] % User time" counter for the individual processes.

What are server performance counters?

Windows Performance Counters provide a high-level abstraction layer that provides a consistent interface for collecting various kinds of system data such as CPU, memory, and disk usage. System administrators often use performance counters to monitor systems for performance or behavior problems.

What are CPU performance counters?

In computers, hardware performance counters (HPC), or hardware counters are a set of special-purpose registers built into modern microprocessors to store the counts of hardware-related activities within computer systems. Advanced users often rely on those counters to conduct low-level performance analysis or tuning.


1 Answers

This sounds like a good candidate for AverageTimer32. See this SO answer for more details.

like image 120
Mark Seemann Avatar answered Oct 15 '22 20:10

Mark Seemann