パフォーマンス・カウンター(問題)

問題

次のソースコードは、パフォーマンスカウンタを作成するCreateCountersメソッドのソースコードです。

なお、左端の数字は参考のために追加した行数です。

Counter1 がWindowsパフォーマンス・モニタ(PerfMon)で使用可能であることを確認するため、11行目に適切なコードを1つ選択しなさい。

ソースコード

01 void CreateCounters() {
02     if (!PerformanceCounterCategory.Exists("Contoso")) {
03         var counters = new CounterCreationDataCollection();
04         var ccdCounter1 = new CounterCreationData{
05             CounterName = "Counter1",
06             CounterType = PerformanceCounterType.SampleFraction;
07         };
08         counters.Add(ccdCounter1);
09         var ccdCounter2 = new CounterCreationData{
10             CounterName = "Counter2";
11
12         };
13         counters.Add(ccdCounter2);
14         PerformanceCounterCategory.Create("Contoso", "Help string", PerformanceCounterCategoryType.MultiInstance, counters);
15     }
16 }

選択肢

  • A. CounterType = PerformanceCounterType.RawBase;

  • B. CounterType = PerformanceCounterType.AverageBase;

  • C. CounterType = PerformanceCounterType.SampleBase;

  • D. CounterType = PerformanceCounterType.CounterMultiBase;

Last updated