Developing with Windows Performance Monitor Counters

by | Updated March 28, 2019 | Development, Dynamics 365 for Finance and Operations

Microsoft’s preferred tool to measure the performance of Windows systems is the Performance Monitor. It provides an analysis chart view with metrics for the Last, Average, Minimum and Maximum values of the performance counters from an imported performance Binary Log File (.blg).

The Performance Monitor is a nice tool to view one file at a time, but sometimes it can become time consuming and limited. However, there is good news. Windows Performance monitor counters can be extracted and developed by software to provide automation and customization.

PowerShell

PowerShell is a Microsoft task-based command-line shell and scripting language, and it can be used to parse performance counter instances into objects imported from performance files. Also, it is able to convert Binary Log Files (.blg) into a few other formats, such as Comma Separate Values (.csv) for easier viewing or another software compatibility.

The following is an example from Microsoft of using PowerShell to select data from a performance file and export it to a new file:

Developing with Windows

Click here for more information from Microsoft on Import-Counter.

The Problem with PowerShell

When importing and parsing performance counter instances into objects, it is possible to access the value of each one. Therefore, it is easy enough to calculate straightforward metrics for a data set including Last, Minimum, and Maximum. The not so straightforward metric to calculate is average.

When calculating the average of performance counters, it is important to consider the cardinality of the data. It is even more important when calculating against counters whose values are already an average, such as, the Avg. Disk sec/Read counter. Hence, the above two reasons are why it is confusing to calculate the averages of performance counters. The standard formula for average: total sum/number of items – will not be the correct representation of values from the Performance Monitor. Microsoft recommends developers to use PdhComputeCounterStatistics to correctly calculate averages from performance counter data.

Note: Along with PowerShell, if a user tries to calculate averages after converting a performance file to CSV, it will be incorrect as well.

PdhComputeCounterStatistics (C++)

PdhComputeCounterStatistics is a part of the Windows application programming interface. It can be accessed and used when developing a Microsoft C++ project. It is Microsoft’s recommendation when calculating averages for performance counter data.

To dig in a little further for developers, the PdhComputeCounterStatistic is a C++ function that computes statistics for a certain performance counter from an array of raw values. It then returns a structure that holds the counter statistics – Last, Average, Minimum, Maximum.

The following is the documented syntax from Microsoft for the PdhComputeCounterStatsitcs function.

Developing with Windows

If you want to learn more about Developing with Windows Performance Counters, Click here for more information about these functions, or hit the contact us form below to talk with us.

Related Posts

  • I've been thoroughly enjoying my new Windows 8 phone, and I wanted to take a minute to share some good resources I've found on these phones.  First, this comparison chart…

  • With the announcement of the release of Microsoft Dynamics AX 2012 R2, Microsoft released an updated system requirements document for AX 2012: http://www.microsoft.com/en-us/download/details.aspx?id=11094.  Windows 2012 Server is now supported, but…

  • Today's the big day for Microsoft as Windows 8 is launching.  Many of my Facebook friends have taken pictures of their new Windows Surface machines - I think they have…

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Upcoming Events

december

02dec9:00 am12:00 pmOnline Workshop - Dynamics GP Year End Close (Morning Session)

03dec11:00 am12:00 pmConfab with Stoneridge - Livestream: Live Agents, Power Virtual Agents, Omnichannel – Oh My!

03dec1:00 pm4:00 pmOnline Workshop - Dynamics GP Year End Close (Afternoon Session)

09dec10:00 am10:30 amThe Modern Manufacturer - Manufacturing Policy Management

17dec11:00 am12:00 pmConfab with Stoneridge - Livestream - Technology in 2020: A Year in Review

january

06jan10:00 am10:30 amThe Modern Manufacturer - MRP v MPS – What, When and How

14jan11:00 am12:00 pmConfab with Stoneridge - Livestream - Looking Forward: Predictions for Technology in 2021

20jan10:00 am10:30 amThe Modern Manufacturer - Demand Forecasting Functionality

About Stoneridge
Stoneridge Software is a unique Microsoft Gold Partner, with emphasis on partner. With specialties in Microsoft Dynamics 365, Microsoft Dynamics AX, Microsoft Dynamics NAV, Microsoft Dynamics GP and Microsoft Dynamics CRM, we focus on attracting the most knowledgeable experts in the field to our team, and prioritize delivering stellar solutions with maximum impact for your business. At Stoneridge, we are deeply committed to your results. Each engagement is met with a dedicated team, ready to provide thorough, tailored, and expert service. Based in Minnesota, we intentionally “step into your shoes,” wherever you are. We focus on what you care about, and develop trusting, long-term relationships with our clients.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X