2015-02-10 15 views
3

這是問題。我正在開發一個名爲CreateCounters的方法,它將爲應用程序創建性能計數器。該方法包括以下代碼。選擇PerformanceCounterType

void CreateCounters() 
{ 
    if(!PerformanceCounterCategory.Exists("Contoso")) 
    { 
     var counters = new CounterCreateationDataCollection(); 
     var ccdCounter1 = new CounterCreationData 
     { 
      CounterName = "Counter1"; 
      CounterType = PerformanceCounterType.SampleFraction; 
     }; 
     counters.Add(ccdCounter1); 
     var ccdCounter2 = new CounterCreationData 
     { 
      CounterName = "Counter2"; 
      // need insert PerformanceCounterType 
     }; 
     counters.Add(ccdCounter2); 
     PerformanceCounterCategory.Create("Contoso","Help dtring", 
     PerformanceCounterCategoryType.MultiInstance, counters); 
    } 
} 

我需要確保Counter1可用於Windows性能監視器(PerfMon)。你應該插入哪個代碼段?

有四種選擇。

A. CounterType = PerformanccCounterType.RawBase 
B. CounterType = PerformanceCounterType.AverageBase 
C. CounterType = PerformanceCounterType.SampleBase 
D. CounterType = PerformanceCounterType.CounterMultiBase 

我不知道哪一個,爲什麼?

回答

1

C. CounterType = PerformanceCounterType.SampleBase