An application can use either the Performance Data Helper (PDH) functions or the
RegQueryValueEx function with HKEY_PERFORMANCE_DATA to collect performance data information of any performance object. This article explains the LogicalDisk and PhysicalDisk counter types that changed from Microsoft Windows NT 4.0 to Microsoft Windows 2000 and Microsoft WIndows XP.
Windows 2000 and Windows XP added a new counter, % Idle Time, to both logical and physical disks. It also changed the type of some counter data. The remainder of this article discusses the disk counters on Windows NT 4.0 and on Windows 2000 and Windows XP.
Windows NT 4.0 Disk Counters
On Windows NT 4.0, the LogicalDisk and PhysicalDisk performance objects have the following counter definitions:
Collapse this tableExpand this table
| Counter Name | Counter Index | Counter Type |
|---|
| % Disk Time | 200 | PERF_COUNTER_TIMER |
| % Disk Read Time | 202 | PERF_COUNTER_TIMER |
| % Disk Write Time | 204 | PERF_COUNTER_TIMER |
| Avg. Disk Queue Length | 1400 | PERF_COUNTER_LARGE_QUEUELEN_TYPE |
| Avg. Disk Read Queue Length | 1402 | PERF_COUNTER_LARGE_QUEUELEN_TYPE |
| Avg. Disk Write Queue Length | 1404 | PERF_COUNTER_LARGE_QUEUELEN_TYPE |
The calculation for PERF_COUNTER_TIMER counter type is performed as follows:
Collapse this tableExpand this table
| Element | Value |
|---|
| X | CounterData |
| Y | PerfTime from PERF_DATA_BLOCK |
| Time base | PerfFreq |
| Data Size | 8 Bytes |
| Display Suffix | % |
| Calculation | 100*(X1-X0)/(Y1-Y0) |
- X0 = counter value from first measurement.
- X1 = counter value from second measurement.
- Y0 = time from the PERF_DATA_BLOCK.PerfTime member for the first measurement.
- Y1 = time from the PERF_DATA_BLOCK.PerfTime member for the second measurement.
The calculation for PERF_COUNTER_LARGE_QUEUELEN_TYPE counter type is performed as follows:
Collapse this tableExpand this table
| Element | Value |
|---|
| X | CounterData |
| Y | PerfTime from PERF_DATA_BLOCK |
| Time base | PerfFreq |
| Data Size | 8 Bytes |
| Display Suffix | No suffix |
| Calculation | (X1-X0)/(Y1-Y0) |
- X0 = counter value from first measurement.
- X1 = counter value from second measurement.
- Y0 = time from the PERF_DATA_BLOCK.PerfTime member for the first measurement.
- Y1 = time from the PERF_DATA_BLOCK.PerfTime member for the second measurement.
Windows 2000 and Windows XP Disk Counters
On Windows 2000 and Windows XP, the % Time counters in LogicalDisk as well as PhysicalDisk performance objects are changed to use precision counters. Precision counters consist of two counter values:
- The counter data of the event that is being monitored.
- The "clock" time in the same units as the first item.This is when the measurement was made.
A precision counter consists of the performance data object and a timestamp counter immediately following it with the same counter index. Precision counters are used where the standard system timers are not precise enough for accurate readings. The performance service that is supplying the performance data provides a timestamp at the same time, which eliminates any error that is caused by small and variable lapses between the time the system timestamp is captured and when the data is collected from the performance DLL.
The LogicalDisk and PhysicalDisk performance objects have the following counter definitions on Windows 2000 and Windows XP:
Collapse this tableExpand this table
| Counter Name | Counter Index | Counter Type |
|---|
| % Disk Time | 200 | PERF_PRECISION_100NS_TIMER |
| % Disk Time | 200 | PERF_PRECISION_TIMESTAMP |
| % Disk Read Time | 202 | PERF_PRECISION_100NS_TIMER |
| % Disk Read Time | 202 | PERF_PRECISION_TIMESTAMP |
| % Disk Write Time | 204 | PERF_PRECISION_100NS_TIMER |
| % Disk Write Time | 204 | PERF_PRECISION_TIMESTAMP |
| % Idle Time | 1482 | PERF_PRECISION_100NS_TIMER |
| % Idle Time | 1482 | PERF_PRECISION_TIMESTAMP |
| Avg. Disk Queue Length | 1400 | PERF_COUNTER_100NS_QUEUELEN_TYPE |
| Avg. Disk Read Queue Length | 1402 | PERF_COUNTER_100NS_QUEUELEN_TYPE |
| Avg. Disk Write Queue Length | 1404 | PERF_COUNTER_100NS_QUEUELEN_TYPE |
The calculation for PERF_PRECISION_100NS_TIMER counter type is performed as follows:
Collapse this tableExpand this table
| Element | Value |
|---|
| X | CounterData |
| Y | N/A |
| Time base | PerfTime100nSec from PERF_DATA_BLOCK |
| Data Size | 8 Bytes |
| Display Suffix | % |
| Calculation | 100*(X1-X0)/(B1-B0) |
- X0 = counter value from first measurement (PERF_PRECISION_100NS_TIMER).
- X1 = counter value from second measurement (PERF_PRECISION_100NS_TIMER).
- B0 = time from the PERF_PRECISION_TIMESTAMP for the first measurement.
- B1 = time from the PERF_PRECISION_TIMESTAMP for the second measurement.
For the PERF_PRECISION_100NS_TIMER counter type, the data collected is in the PERF_PRECISION_100NS_TIMER counter. The timestamp, which is stored in a PERF_PRECISION_TIMESTAMP counter, follows immediately and has the same counter index. For example, after the application has determined the counter index 200 and location of the % Disk Time counter, the precision timestamp base is the counter following it with a counter index of 200.
The calculation for PERF_COUNTER_100NS_QUEUELEN_TYPE counter type is performed as follows:
Collapse this tableExpand this table
| Element | Value |
|---|
| X | CounterData |
| Y | PerfTime100nSec from PERF_DATA_BLOCK |
| Time base | 100NS |
| Data Size | 8 Bytes |
| Display Suffix | No suffix |
| Calculation | (X1-X0)/(Y1-Y0) |
- X0 = counter value from first measurement.
- X1 = counter value from second measurement.
- Y0 = time from the PERF_DATA_BLOCK.PerfTime member for the first measurement.
- Y1 = time from the PERF_DATA_BLOCK.PerfTime member for the second measurement.
For detailed information about how to retrieve these counter values, refer to the
Performance Monitoring topic in Microsoft Platform SDK or the Microsoft Developer Network (MSDN) documentation, under Base Services.