processor monitor completed.

This commit is contained in:
Zhen Tang 2013-07-07 12:18:16 +08:00
parent 59b139f1b1
commit d40dcc35f8
7 changed files with 120 additions and 1 deletions

View File

@ -21,6 +21,15 @@ public:
static double GetInterruptsPerSecond(wchar_t * instanceName, int idleTime);
static double GetDpcTimePercent(wchar_t * instanceName, int idleTime);
static double GetInterruptTimePercent(wchar_t * instanceName, int idleTime);
static double GetDpcsQueuedPerSecond(wchar_t * instanceName, int idleTime);
static double GetDpcRate(wchar_t * instanceName);
static double GetIdleTimePercent(wchar_t * instanceName, int idleTime);
static double GetC1TimePercent(wchar_t * instanceName, int idleTime);
static double GetC2TimePercent(wchar_t * instanceName, int idleTime);
static double GetC3TimePercent(wchar_t * instanceName, int idleTime);
static double GetC1TransitionsPerSecond(wchar_t * instanceName, int idleTime);
static double GetC2TransitionsPerSecond(wchar_t * instanceName, int idleTime);
static double GetC3TransitionsPerSecond(wchar_t * instanceName, int idleTime);
};
class MONITOR_API ProcessorInformation

View File

@ -80,19 +80,100 @@ double Processor::GetInterruptTimePercent(wchar_t * instanceName, int idleTime)
}
// DPCs Queued/sec
double Processor::GetDpcsQueuedPerSecond(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\DPCs Queued/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// DPC Rate
double Processor::GetDpcRate(wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\DPC Rate";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// % Idle Time
double Processor::GetIdleTimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% Idle Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % C1 Time
double Processor::GetC1TimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% C1 Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % C2 Time
double Processor::GetC2TimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% C2 Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % C3 Time
double Processor::GetC3TimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% C3 Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// C1 Transitions/sec
double Processor::GetC1TransitionsPerSecond(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\C1 Transitions/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// C2 Transitions/sec
double Processor::GetC2TransitionsPerSecond(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\C2 Transitions/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// C3 Transitions/sec
double Processor::GetC3TransitionsPerSecond(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\C3 Transitions/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}

View File

@ -15,4 +15,13 @@ public:
static double GetInterruptsPerSecond(wchar_t * instanceName, int idleTime);
static double GetDpcTimePercent(wchar_t * instanceName, int idleTime);
static double GetInterruptTimePercent(wchar_t * instanceName, int idleTime);
static double GetDpcsQueuedPerSecond(wchar_t * instanceName, int idleTime);
static double GetDpcRate(wchar_t * instanceName);
static double GetIdleTimePercent(wchar_t * instanceName, int idleTime);
static double GetC1TimePercent(wchar_t * instanceName, int idleTime);
static double GetC2TimePercent(wchar_t * instanceName, int idleTime);
static double GetC3TimePercent(wchar_t * instanceName, int idleTime);
static double GetC1TransitionsPerSecond(wchar_t * instanceName, int idleTime);
static double GetC2TransitionsPerSecond(wchar_t * instanceName, int idleTime);
static double GetC3TransitionsPerSecond(wchar_t * instanceName, int idleTime);
};

View File

@ -21,6 +21,15 @@ public:
static double GetInterruptsPerSecond(wchar_t * instanceName, int idleTime);
static double GetDpcTimePercent(wchar_t * instanceName, int idleTime);
static double GetInterruptTimePercent(wchar_t * instanceName, int idleTime);
static double GetDpcsQueuedPerSecond(wchar_t * instanceName, int idleTime);
static double GetDpcRate(wchar_t * instanceName);
static double GetIdleTimePercent(wchar_t * instanceName, int idleTime);
static double GetC1TimePercent(wchar_t * instanceName, int idleTime);
static double GetC2TimePercent(wchar_t * instanceName, int idleTime);
static double GetC3TimePercent(wchar_t * instanceName, int idleTime);
static double GetC1TransitionsPerSecond(wchar_t * instanceName, int idleTime);
static double GetC2TransitionsPerSecond(wchar_t * instanceName, int idleTime);
static double GetC3TransitionsPerSecond(wchar_t * instanceName, int idleTime);
};
class MONITOR_API ProcessorInformation

View File

@ -21,6 +21,15 @@ public:
static double GetInterruptsPerSecond(wchar_t * instanceName, int idleTime);
static double GetDpcTimePercent(wchar_t * instanceName, int idleTime);
static double GetInterruptTimePercent(wchar_t * instanceName, int idleTime);
static double GetDpcsQueuedPerSecond(wchar_t * instanceName, int idleTime);
static double GetDpcRate(wchar_t * instanceName);
static double GetIdleTimePercent(wchar_t * instanceName, int idleTime);
static double GetC1TimePercent(wchar_t * instanceName, int idleTime);
static double GetC2TimePercent(wchar_t * instanceName, int idleTime);
static double GetC3TimePercent(wchar_t * instanceName, int idleTime);
static double GetC1TransitionsPerSecond(wchar_t * instanceName, int idleTime);
static double GetC2TransitionsPerSecond(wchar_t * instanceName, int idleTime);
static double GetC3TransitionsPerSecond(wchar_t * instanceName, int idleTime);
};
class MONITOR_API ProcessorInformation

View File

@ -17,7 +17,8 @@ int _tmain(int argc, _TCHAR* argv[])
while(1)
{
printf("%lf\n",Processor::GetInterruptTimePercent(L"_Total",1500));
printf("%lf\n",Processor::GetC3TransitionsPerSecond(L"_Total",1500));
Sleep(500);
}
return 0;
}

View File

@ -2,6 +2,7 @@
#pragma comment(lib,"../x64/Debug/Monitor.lib")
#include <Windows.h>
#include <tchar.h>
#include <iostream>