系统性能参数详解

常用指标
Cache - Level 2 cache. Data Map Hits %
Logical Disk* - % Free Space
Memory* - Counters:
Pages/Sec - How much RAM and virtual memory on the hard drive are being swapped. If above 5 or 6 on average, more RAM is needed.
Network interface* - Counters:
Bytes Total/sec
Objects - Process and thread counts
Paging file - Virtual memory. Counters:
% Usage - The amount of the paging file being used. Create a larger paging file or add RAM if the number is near 100%.
Physical disk - Counters:
Disk Queue Length - The number of disk reads and writes in queue to be done. - If above 4 or 5 on average, a faster hard drive is needed.
Average disk Sec/Transfer
% disk time - The percent of time the disk is busy doing reads or writes. A high number near 100% indicates a disk or drive controller bottleneck.
Process - Currently running programs. Counters:
% Processor Time - The percent of time the processor is used by this process object including all its threads.
Processor* - Counters:
% Processor Time - A number close to 100% indicates the processor is a bottleneck.
Redirector
Server - Counters:
Bytes Total/Sec - The total number of bytes sent through or received through all network cards on a computer by the server service.
System - NT Performance. File Read or Write Operations/Sec
Thread - Thread performance. Counters:
% Processor Time - The percent of time the processor is used by this thread object.
http://www.comptechdoc.org/os/windows/win2k/win2kperformance.html(关于性能的大多数指标都在这里)

实例介绍
http://www.codeproject.com/KB/system/cpuusageByDudiAvramov.aspx
实例中的关键概念

1) object,instance,counter
对应的场景,计算线程IE的CPU使用率:
object -->线程
instance-->IE
counter-->CPU使用率
2)windows下的性能计算模型
在windows下,所有的性能对象(object instance 对应的counter)的数据存储在winperf.h定义的结构体中,我们要做的就是遍历这些结构体,取出我们要使用的数据。一个重要的前提是注册表中相关选项必须设置正确。
BOOL CCpuUsage::EnablePerformaceCounters(BOOL bEnable)
{
if (GetPlatform() != WIN2K_XP)
return TRUE;

CRegKey regKey;
if (regKey.Open(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\PerfOS\\Performance") != ERROR_SUCCESS)
return FALSE;

regKey.SetValue(!bEnable, "Disable Performance Counters");
regKey.Close();

if (regKey.Open(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\PerfProc\\Performance") != ERROR_SUCCESS)
return FALSE;

regKey.SetValue(!bEnable, "Disable Performance Counters");
regKey.Close();

return TRUE;
}

接着传入我们相应的object,instance,counter来获取相关数值。
#define SYSTEM_OBJECT_INDEX 2 // 'System' object
#define PROCESS_OBJECT_INDEX 230 // 'Process' object
#define PROCESSOR_OBJECT_INDEX 238 // 'Processor' object
#define TOTAL_PROCESSOR_TIME_COUNTER_INDEX 240 // '% Total processor time' counter (valid in WinNT under 'System' object)
#define PROCESSOR_TIME_COUNTER_INDEX 6 // '% processor time' counter (for Win2K/XP)
//不同的平台对应的objectindex不同
switch (Platform)
{
case WINNT:
dwObjectIndex = SYSTEM_OBJECT_INDEX;
dwCpuUsageIndex = TOTAL_PROCESSOR_TIME_COUNTER_INDEX;
break;
case WIN2K_XP:
dwObjectIndex = PROCESSOR_OBJECT_INDEX;
dwCpuUsageIndex = PROCESSOR_TIME_COUNTER_INDEX;
strcpy(szInstance,"_Total");
break;
default:
return -1;
}

你可能感兴趣的:(thread,windows,IE,XP,performance)