Which code segment should you insert at line 16?

You are developing a method named CreateCounters that will create performance counters for an
application. The method includes the following code. (Line numbers are included for reference only.)
01 void CreateCounters()
02 {
03 if (!PerformanceCounterCategory.Exists(“Contoso”))
04 {
05 var counters = new CounterCreationDataCollection();
06 var ccdCounter1 = new CounterCreationData
07 {
08 CounterName = “Counter1”,09 CounterType = PerformanceCounterType.AverageTimer32
11 };
12 counters.Add(ccdCounter1);
13 var ccdCounter2 = new CounterCreationData
14 {
15 CounterName = “Counter2”,
16
17 };
18 counters.Add(ccdCounter2);
19 PerformanceCounterCategory.Create(“Contoso”, “Help string”,
20 PerformanceCounterCategoryType.MultiInstance, counters);
21 }
22 }
You need to ensure that Counter2 is available for use in Windows Performance Monitor (PerfMon). Which
code segment should you insert at line 16?

You are developing a method named CreateCounters that will create performance counters for an
application. The method includes the following code. (Line numbers are included for reference only.)
01 void CreateCounters()
02 {
03 if (!PerformanceCounterCategory.Exists(“Contoso”))
04 {
05 var counters = new CounterCreationDataCollection();
06 var ccdCounter1 = new CounterCreationData
07 {
08 CounterName = “Counter1”,09 CounterType = PerformanceCounterType.AverageTimer32
11 };
12 counters.Add(ccdCounter1);
13 var ccdCounter2 = new CounterCreationData
14 {
15 CounterName = “Counter2”,
16
17 };
18 counters.Add(ccdCounter2);
19 PerformanceCounterCategory.Create(“Contoso”, “Help string”,
20 PerformanceCounterCategoryType.MultiInstance, counters);
21 }
22 }
You need to ensure that Counter2 is available for use in Windows Performance Monitor (PerfMon). Which
code segment should you insert at line 16?

A.
CounterType = PerformanceCounterType.RawBase;

B.
CounterType = PerformanceCounterType.AverageBase;

C.
CounterType = PerformanceCounterType.SampleBase;

D.
CounterType = PerformanceCounterType.CounterMultiBase;

Explanation:
PerformanceCounterType.AverageTimer32 – An average counter that measures the time it takes, on
average, to complete a process or operation. Counters of this type display a ratio of the total elapsed time of
the sample interval to the number of processes or operations completed during that time. This counter type
measures time in ticks of the system clock. Formula: ((N 1 -N 0)/F)/(B 1 -B 0), where N 1 and N 0 are
performance counter readings, B 1 and B 0 are their corresponding AverageBase values, and F is the number
of ticks per second. The value of F is factored into the equation so that the result can be displayed in seconds.
Thus, the numerator represents the numbers of ticks counted during the last sample interval, F represents the
frequency of the ticks, and the denominator represents the number of operations completed during the last
sample interval. Counters of this type include PhysicalDisk\\ Avg. Disk sec/Transfer.
PerformanceCounterType.AverageBase – A base counter that is used in the calculation of time or count
averages, such as AverageTimer32 and AverageCount64. Stores the denominator for calculating a counter to
present “time per operation” or “count per operation”..
http://msdn.microsoft.com/en-us/library/system.diagnostics.performancecountertype.aspx



Leave a Reply 2

Your email address will not be published. Required fields are marked *


yizhak

yizhak

The Correct Answer is : C

Explanation:
PerformanceCounterType.SampleBase – A base counter that stores the number of sampling interrupts
taken and is used as a denominator in the sampling fraction. The sampling fraction is the number of samples
that were 1 (or true) for a sample interrupt. Check that this value is greater than zero before using it as the
denominator in a calculation of SampleFraction.
PerformanceCounterType.SampleFraction – A percentage counter that shows the average ratio of hits
to all operations during the last two sample intervals. Formula: ((N 1 – N 0) / (D 1 – D 0)) x 100, where the
numerator represents the number of successful operations during the last sample interval, and the denominator
represents the change in the number of all operations (of the type measured) completed during the sample
interval, using counters of type SampleBase. Counters of this type include Cache\Pin Read Hits %.