Windowsのパフォーマンスカウンタのアプリケーション(PART1)
Windowsのパフォーマンスカウンタのアプリケーション(PART2)
Windowsのパフォーマンスカウンタのアプリケーション(PART3)
Windowsのパフォーマンスカウンタのアプリケーション(PART4)
{
// PerformanceCounter(区分名、CounterName、InstanceNameは)
performanceNetCounterCategory = newPerformanceCounterCategory( "ネットワーク・インタフェース")。
インターフェイス= performanceNetCounterCategory.GetInstanceNames()。
int型の長さ= interfaces.Length。
(長さ> 0)であれば
{
trafficSentCounters = newPerformanceCounter [長さ]。
trafficReceivedCounters = newPerformanceCounter [長さ]。
}
(INT iは= 0; I <長さ、I ++)のために
{
//は、新しい読み取り専用インスタンスPerformanceCounterクラスを初期化します。
//第一引数:「区分名」 - パフォーマンスカウンタパフォーマンスカウンタカテゴリ(パフォーマンスオブジェクト)に関連付けられた名前。
//第二引数:「CounterName」 - パフォーマンスカウンタの名前。
//三番目のパラメータ:「instanceNameの」 - パフォーマンスカウンタクラスのインスタンスの名前、空の文字列カテゴリが(「」)のために、単一のインスタンスを含んでいる場合。
trafficReceivedCounters [I] =新しいPerformanceCounter( "ネットワークインターフェイス"、 "送信バイト/秒"、インターフェイス[I])。
trafficSentCounters [I] =新しいPerformanceCounter( "ネットワークインターフェイス"、 "送信バイト/秒"、インターフェイス[I])。
}
//网络接口所有名称的列表
ため(INT iが= 0; I <長さ、I ++)
{
Console.WriteLineを( "名前netinterfaceの:{0}"、performanceNetCounterCategory.GetInstanceNames()[I])。
}
}
公共ボイドgetProcessorCpuTime()
{
フロートTMP = cpuProcessorTime.NextValue()。
CPUProcessorTime =(フロート)(恐らくMath.round((二重)TMP、1))。
// Environment.ProcessorCount:返回内核总数
}
公共ボイドgetCpuPrivilegedTime()
{
フロートTMP = cpuPrivilegedTime.NextValue()。
CPUPrivilegedTime =(フロート)(恐らくMath.round((二重)TMP、1))。
}
公共ボイドgetCpuinterruptTime()
{
フロートTMP = cpuInterruptTime.NextValue()。
CPUInterruptTime =(フロート)(恐らくMath.round((二重)TMP、1))。
}
公共ボイドgetcpuDPCTime()
{
フロートTMP = cpuDPCTime.NextValue()。
CPUDPCTime =(フロート)(恐らくMath.round((二重)TMP、1))。
}
公共ボイドgetPageFile()
{
ページファイル= pageFile.NextValue()。
}
公共ボイドgetProcessorQueueLengh()
{
ProcessorQueueLengh = processorQueueLengh.NextValue()。
}
公共ボイドgetMemAvailable()
{
MEMAvailable = memAvailable.NextValue()。
}
公共ボイドgetMemCommited()
{
MEMCommited = memCommited.NextValue()/(1024 * 1024)。
}
公共ボイドgetMemCommitLimit()
{
MEMCommitLimit = memCommitLimit.NextValue()/(1024 * 1024)。
}
公共ボイドgetMemCommitedPerc()
{
フロートTMP = memCommitedPerc.NextValue()。
//メモリの値が制限値をコミット返します。
MEMCommitedPerc =(フロート)(恐らくMath.round((二重)TMP、1))。
}
公共ボイドgetMemPoolPaged()
{
フロートTMP = memPollPaged.NextValue()/(1024 * 1024)。
MEMPoolPaged =(フロート)(恐らくMath.round((二重)TMP、1))。
}
公共ボイドgetMemPoolNonPaged()
{
フロートTMP = memPollNonPaged.NextValue()/(1024 * 1024)。
MEMPoolNonPaged =(フロート)(恐らくMath.round((二重)TMP、1))。
}
公共ボイドgetMemCachedBytes()
{
//キャッシュされたメモリのMBの値を返します。
MEMCached = memCached.NextValue() / (1024 * 1024);
}
public void getDiskQueueLengh()
{
DISCQueueLengh = diskQueueLengh.NextValue();
}
public void getDiskRead()
{
float tmp=diskRead.NextValue()/1024;
DISKRead = (float)(Math.Round((double)tmp,1));
}
public void getDiskWrite()
{
float tmp=diskWrite.NextValue()/1024;
DISKWrite = (float)(Math.Round((double)tmp,1)); // round 1 digit decimal
}
public void getDiskAverageTimeRead()
{
float tmp = diskAverageTimeRead.NextValue() * 1000;
DISKAverageTimeRead = (float)(Math.Round((double)tmp, 1)); // round 1 digit decimal
}
public void getDiskAverageTimeWrite()
{
float tmp = diskAverageTimeWrite.NextValue()*1000;
DISKAverageTimeWrite = (float)(Math.Round((double)tmp, 1)); // round 1 digit decimal
}
public void getDiskTime()
{
float tmp = diskTime.NextValue();
DISKTime = (float)(Math.Round((double)tmp, 1));
}
public void getHandleCountCounter()
{
HANDLECountCounter = handleCountCounter.NextValue();
}
public void getThreadCount()
{
THREADCount = threadCount.NextValue();
}
public void getContentSwitches()
{
CONTENTSwitches = (int)Math.Ceiling(contentSwitches.NextValue());
}
public void getsystemCalls()
{
SYSTEMCalls = (int)Math.Ceiling(systemCalls.NextValue());
}
public void getCurretTrafficSent()
{
int length = interfaces.Length;
float sendSum = 0.0F;
for (int i = 0; i < length; i++)
{
sendSum += trafficSentCounters[i].NextValue();
}
float tmp = 8 * (sendSum / 1024);
NetTrafficSend = (float)(Math.Round((double)tmp, 1));
}
public void getCurretTrafficReceived()
{
int length = interfaces.Length;
float receiveSum = 0.0F;
for (int i = 0; i < length; i++)
{
receiveSum += trafficReceivedCounters[i].NextValue();
}
float tmp = 8 * (receiveSum / 1024);
NetTrafficReceive = (float)(Math.Round((double)tmp, 1));
}
public void getSampleTime()
{
SamplingTime =DateTime.Now;
}
}
Windows性能计数器应用(PART1)
Windows性能计数器应用(PART2)
Windows性能计数器应用(PART3)
Windows性能计数器应用(PART4)
Windows性能计数器应用(PART6)