gpt4 book ai didi

c# - 选择性能计数器类型

转载 作者:太空狗 更新时间:2023-10-29 22:30:48 25 4
gpt4 key购买 nike

问题来了。我正在开发一个名为 CreateCounters 的方法,该方法将为应用程序创建性能计数器。该方法包括以下代码。

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

我不知道是哪一个,为什么?

最佳答案

看这个:

https://msdn.microsoft.com/en-us/library/system.diagnostics.performancecountertype%28v=vs.110%29.aspx

那里有一张表显示 PerformanceCounterType.SampleFraction 需要类型为 PerformanceCounterType.SampleBase 的分母

(并且 RawFraction 需要 RawBase 等)

关于c# - 选择性能计数器类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28441713/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com