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?
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.
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.
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.
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.
This sounds like a good candidate for AverageTimer32. See this SO answer for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With