本文整理汇总了C#中System.Diagnostics.CounterCreationData类的典型用法代码示例。如果您正苦于以下问题:C# CounterCreationData类的具体用法?C# CounterCreationData怎么用?C# CounterCreationData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CounterCreationData类属于System.Diagnostics命名空间,在下文中一共展示了CounterCreationData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: LoadTestStarting
private void LoadTestStarting(object sender, EventArgs e)
{
// Delete the category if already exists
if (PerformanceCounterCategory.Exists("AMSStressCounterSet"))
{
PerformanceCounterCategory.Delete("AMSStressCounterSet");
}
CounterCreationDataCollection counters = new CounterCreationDataCollection();
// 1. counter for counting totals: PerformanceCounterType.NumberOfItems32
CounterCreationData totalOps = new CounterCreationData();
totalOps.CounterName = "# operations executed";
totalOps.CounterHelp = "Total number of operations executed";
totalOps.CounterType = PerformanceCounterType.NumberOfItems32;
counters.Add(totalOps);
// 2. counter for counting operations per second:
// PerformanceCounterType.RateOfCountsPerSecond32
CounterCreationData opsPerSecond = new CounterCreationData();
opsPerSecond.CounterName = "# operations / sec";
opsPerSecond.CounterHelp = "Number of operations executed per second";
opsPerSecond.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;
counters.Add(opsPerSecond);
// create new category with the counters above
PerformanceCounterCategory.Create("AMSStressCounterSet", "KeyDelivery Stress Counters", PerformanceCounterCategoryType.SingleInstance, counters);
}
开发者ID:shushengli,项目名称:azure-sdk-for-media-services,代码行数:29,代码来源:InstallperfCountersPlugin.cs
示例2: GetOrCreateCounterCategory
/// <summary>
/// Gets the or create counter category.
/// </summary>
/// <param name="categoryInfo">The category information.</param>
/// <param name="counters">The counters.</param>
/// <returns>PerformanceCounterCategory.</returns>
private static PerformanceCounterCategory GetOrCreateCounterCategory(
PerformanceCounterCategoryInfo categoryInfo, CounterCreationData[] counters)
{
var creationPending = true;
var categoryExists = false;
var categoryName = categoryInfo.CategoryName;
var counterNames = new HashSet<string>(counters.Select(info => info.CounterName));
PerformanceCounterCategory category = null;
if (PerformanceCounterCategory.Exists(categoryName))
{
categoryExists = true;
category = new PerformanceCounterCategory(categoryName);
var counterList = category.GetCounters();
if (category.CategoryType == categoryInfo.CategoryType && counterList.Length == counterNames.Count)
{
creationPending = counterList.Any(x => !counterNames.Contains(x.CounterName));
}
}
if (!creationPending) return category;
if (categoryExists)
PerformanceCounterCategory.Delete(categoryName);
var counterCollection = new CounterCreationDataCollection(counters);
category = PerformanceCounterCategory.Create(
categoryInfo.CategoryName,
categoryInfo.CategoryHelp,
categoryInfo.CategoryType,
counterCollection);
return category;
}
开发者ID:bradsjm,项目名称:DotEmwin,代码行数:41,代码来源:PerformanceCounterManager.cs
示例3: SetupCategory
private static void SetupCategory()
{
if (PerformanceCounterCategory.Exists(CategoryName))
{
PerformanceCounterCategory.Delete(CategoryName);
}
if (!PerformanceCounterCategory.Exists(CategoryName))
{
CounterCreationDataCollection creationDataCollection =
new CounterCreationDataCollection();
CounterCreationData ctrCreationData = new CounterCreationData();
ctrCreationData.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;
ctrCreationData.CounterName = SpeedCounterName;
creationDataCollection.Add(ctrCreationData);
CounterCreationData ctrCreationData2 = new CounterCreationData();
ctrCreationData2.CounterType = PerformanceCounterType.RateOfCountsPerSecond64;
ctrCreationData2.CounterName = SpeedBytesCounterName;
creationDataCollection.Add(ctrCreationData2);
PerformanceCounterCategory.Create(CategoryName,
"Sample TransVault category",
PerformanceCounterCategoryType.MultiInstance,
creationDataCollection);
}
}
开发者ID:shukanov-artyom,项目名称:studies,代码行数:27,代码来源:Program.cs
示例4: InstallCounters
/// <summary>
/// install thge perfmon counters
/// </summary>
public static void InstallCounters()
{
if (!PerformanceCounterCategory.Exists(BabaluCounterDescriptions.CounterCategory))
{
//Create the collection that will hold
// the data for the counters we are
// creating.
CounterCreationDataCollection counterData = new CounterCreationDataCollection();
//Create the CreationData object.
foreach (string counter in BabaluCounterDescriptions.BabaluCounters)
{
CounterCreationData BabaluCounter = new CounterCreationData();
// Set the counter's type to NumberOfItems32
BabaluCounter.CounterType = PerformanceCounterType.NumberOfItems32;
//Set the counter's name
BabaluCounter.CounterName = counter;
//Add the CreationData object to our
//collection
counterData.Add(BabaluCounter);
}
//Create the counter in the system using the collection.
PerformanceCounterCategory.Create(BabaluCounterDescriptions.CounterCategory, BabaluCounterDescriptions.CategoryDescription,
PerformanceCounterCategoryType.SingleInstance, counterData);
}
}
开发者ID:CalypsoSys,项目名称:Babalu_rProxy,代码行数:33,代码来源:BabaluCounterDescriptions.cs
示例5: InstallCounters
/// <summary>
/// Starts the install
/// </summary>
public static void InstallCounters()
{
Logger.Debug("Starting installation of PerformanceCounters ");
var categoryName = "NServiceBus";
var counterName = "Critical Time";
if (PerformanceCounterCategory.Exists(categoryName))
{
Logger.Warn("Category " + categoryName + " already exist, going to delete first");
PerformanceCounterCategory.Delete(categoryName);
}
var data = new CounterCreationDataCollection();
var c1 = new CounterCreationData(counterName, "Age of the oldest message in the queue",
PerformanceCounterType.NumberOfItems32);
data.Add(c1);
PerformanceCounterCategory.Create(categoryName, "NServiceBus statistics",
PerformanceCounterCategoryType.MultiInstance, data);
Logger.Debug("Installation of PerformanceCounters successful.");
}
开发者ID:vimaire,项目名称:NServiceBus_2.0,代码行数:28,代码来源:PerformanceCounterInstallation.cs
示例6: CreateCounter
public static void CreateCounter()
{
CounterCreationDataCollection col = new CounterCreationDataCollection();
// Create two custom counter objects.
CounterCreationData addCounter = new CounterCreationData();
addCounter.CounterName = "AddCounter";
addCounter.CounterHelp = "Custom Add counter ";
addCounter.CounterType = PerformanceCounterType.NumberOfItemsHEX32;
// Add custom counter objects to CounterCreationDataCollection.
col.Add(addCounter);
// Bind the counters to a PerformanceCounterCategory
// Check if the category already exists or not.
if (!PerformanceCounterCategory.Exists("MyCategory"))
{
PerformanceCounterCategory category =
PerformanceCounterCategory.Create("MyCategory", "My Perf Category Description ", PerformanceCounterCategoryType.Unknown, col);
}
else
{
Console.WriteLine("Counter already exists");
}
}
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:25,代码来源:client.cs
示例7: InitializeClicked
private void InitializeClicked(object sender, RoutedEventArgs e)
{
if (PerformanceCounterCategory.Exists(CategoryName))
{
PerformanceCounterCategory.Delete(CategoryName);
}
if (!PerformanceCounterCategory.Exists(CategoryName))
{
CounterCreationDataCollection creationDataCollection =
new CounterCreationDataCollection();
CounterCreationData ctrCreationData = new CounterCreationData();
ctrCreationData.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;
ctrCreationData.CounterName = SpeedCounterName;
creationDataCollection.Add(ctrCreationData);
CounterCreationData ctrCreationData2 = new CounterCreationData();
ctrCreationData2.CounterType = PerformanceCounterType.RateOfCountsPerSecond64;
ctrCreationData2.CounterName = SpeedBytesCounterName;
creationDataCollection.Add(ctrCreationData2);
PerformanceCounterCategory.Create(CategoryName,
"Sample Custom category",
PerformanceCounterCategoryType.MultiInstance,
creationDataCollection);
}
currentContainer = new CountersContainer()
{
BytesPerSecCounter = SetupCounter(CategoryName, SpeedCounterName, "Task " + currentTask),
ItemsPerSecCounter = SetupCounter(CategoryName, SpeedBytesCounterName, "Task " + currentTask)
};
}
开发者ID:shukanov-artyom,项目名称:studies,代码行数:32,代码来源:MainWindow.xaml.cs
示例8: CreateCounters
private static void CreateCounters(string groupName)
{
if (PerformanceCounterCategory.Exists(groupName))
{
PerformanceCounterCategory.Delete(groupName);
}
var counters = new CounterCreationDataCollection();
var totalOps = new CounterCreationData
{
CounterName = "Messages Read",
CounterHelp = "Total number of messages read",
CounterType = PerformanceCounterType.NumberOfItems32
};
counters.Add(totalOps);
var opsPerSecond = new CounterCreationData
{
CounterName = "Messages Read / Sec",
CounterHelp = "Messages read per second",
CounterType = PerformanceCounterType.RateOfCountsPerSecond32
};
counters.Add(opsPerSecond);
PerformanceCounterCategory.Create(groupName, "PVC", PerformanceCounterCategoryType.SingleInstance, counters);
}
开发者ID:thefringeninja,项目名称:Event-handling,代码行数:27,代码来源:WMIQueueProcessorInstrumentation.cs
示例9: CustomInstaller
public CustomInstaller()
{
string loadPerf = Environment.GetFolderPath(Environment.SpecialFolder.System) + @"\loadperf.dll";
if (File.Exists(loadPerf))
{
// add in a perf mon installer
PerformanceCounterInstaller p = new PerformanceCounterInstaller();
p.CategoryName = Resources.PerfMonCategoryName;
p.CategoryHelp = Resources.PerfMonCategoryHelp;
p.CategoryType = PerformanceCounterCategoryType.SingleInstance;
CounterCreationData ccd1 = new CounterCreationData(
Resources.PerfMonHardProcName,
Resources.PerfMonHardProcHelp,
PerformanceCounterType.NumberOfItems32);
CounterCreationData ccd2 = new CounterCreationData(
Resources.PerfMonSoftProcName,
Resources.PerfMonSoftProcHelp,
PerformanceCounterType.RateOfCountsPerSecond32);
p.Counters.Add(ccd1);
p.Counters.Add(ccd2);
perfMonIndex = Installers.Add(p);
}
}
开发者ID:rykr,项目名称:connector-net,代码行数:26,代码来源:Installer.cs
示例10: AddRange
public void AddRange (CounterCreationData[] value)
{
foreach (CounterCreationData v in value)
{
Add (v);
}
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:CounterCreationDataCollection.cs
示例11: SetupCategory
private bool SetupCategory()
{
// PerformanceCounterCategory.Delete("DCC2012");
if (!PerformanceCounterCategory.Exists(this.categoryName))
{
CounterCreationDataCollection counterDataCollection = new CounterCreationDataCollection();
// Add the counter.
CounterCreationData averageCount64 = new CounterCreationData();
averageCount64.CounterType = PerformanceCounterType.NumberOfItems32;
averageCount64.CounterName = "GetData Call Count";
counterDataCollection.Add(averageCount64);
CounterCreationData averageCount641 = new CounterCreationData();
averageCount641.CounterType = PerformanceCounterType.CounterTimer;
averageCount641.CounterName = "GetData Execution Time";
counterDataCollection.Add(averageCount641);
// Create the category.
PerformanceCounterCategory.Create("DCC2012", "Desert Code Camp.",
PerformanceCounterCategoryType.SingleInstance, counterDataCollection);
return (true);
}
else
{
Console.WriteLine("Category exists - AverageCounter64SampleCategory");
return (false);
}
}
开发者ID:razorKramer,项目名称:Demo,代码行数:31,代码来源:PerformanceCounterAttribute.cs
示例12: Main
static void Main(string[] args)
{
if (PerformanceCounterCategory.Exists("DontStayIn"))
PerformanceCounterCategory.Delete("DontStayIn");
// Create the collection container
CounterCreationDataCollection counters = new CounterCreationDataCollection();
// Create counter #1 and add it to the collection
CounterCreationData dsiPages = new CounterCreationData();
dsiPages.CounterName = "DsiPages per sec";
dsiPages.CounterHelp = "Total number of dsi pages per second.";
dsiPages.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;
counters.Add(dsiPages);
// Create counter #3 and add it to the collection
CounterCreationData genTime = new CounterCreationData();
genTime.CounterName = "DsiPage generation time";
genTime.CounterHelp = "Average time to generate a page.";
genTime.CounterType = PerformanceCounterType.AverageTimer32;
counters.Add(genTime);
CounterCreationData genTimeBase = new CounterCreationData();
genTimeBase.CounterName = "DsiPage generation time base";
genTimeBase.CounterHelp = "Average time to generate a page base.";
genTimeBase.CounterType = PerformanceCounterType.AverageBase;
counters.Add(genTimeBase);
// Create the category and all of the counters.
PerformanceCounterCategory.Create("DontStayIn", "Performance counters for DontStayIn.", PerformanceCounterCategoryType.SingleInstance, counters);
Console.WriteLine("Done!");
Console.ReadLine();
}
开发者ID:davelondon,项目名称:dontstayin,代码行数:35,代码来源:Program.cs
示例13: InitializeCounters
private static void InitializeCounters()
{
try
{
var counterDatas =
new CounterCreationDataCollection();
// Create the counters and set their properties.
var cdCounter1 =
new CounterCreationData();
var cdCounter2 =
new CounterCreationData();
cdCounter1.CounterName = "Total Requests Handled";
cdCounter1.CounterHelp = "Total number of requests handled";
cdCounter1.CounterType = PerformanceCounterType.NumberOfItems64;
cdCounter2.CounterName = "Requests Per Secpmd";
cdCounter2.CounterHelp = "Average number of requests per second.";
cdCounter2.CounterType = PerformanceCounterType.RateOfCountsPerSecond64;
// Add both counters to the collection.
counterDatas.Add(cdCounter1);
counterDatas.Add(cdCounter2);
// Create the category and pass the collection to it.
PerformanceCounterCategory.Create(
"Socket Service Data Stats", "Stats for the socket service.",
PerformanceCounterCategoryType.MultiInstance, counterDatas);
}
catch (Exception ex)
{
Logger.Error(ex.ToString());
}
}
开发者ID:soshimozi,项目名称:SocketServer,代码行数:34,代码来源:SocketService.cs
示例14: CreatePerformanceCategory
public void CreatePerformanceCategory()
{
const string category = "MikePerfSpike";
if (!PerformanceCounterCategory.Exists(category))
{
var counters = new CounterCreationDataCollection();
// 1. counter for counting values
var totalOps = new CounterCreationData
{
CounterName = "# of operations executed",
CounterHelp = "Total number of operations that have been executed",
CounterType = PerformanceCounterType.NumberOfItems32
};
counters.Add(totalOps);
// 2. counter for counting operations per second
var opsPerSecond = new CounterCreationData
{
CounterName = "# of operations/second",
CounterHelp = "Number of operations per second",
CounterType = PerformanceCounterType.RateOfCountsPerSecond32
};
counters.Add(opsPerSecond);
PerformanceCounterCategory.Create(
category,
"An experiment",
PerformanceCounterCategoryType.MultiInstance,
counters);
}
}
开发者ID:ngbrown,项目名称:EasyNetQ,代码行数:33,代码来源:PerformanceCounterSpike.cs
示例15: InstallPerformanceCounters
private void InstallPerformanceCounters()
{
if (!PerformanceCounterCategory.Exists("nHydrate"))
{
var counters = new CounterCreationDataCollection();
// 1. counter for counting totals: PerformanceCounterType.NumberOfItems32
var totalAppointments = new CounterCreationData();
totalAppointments.CounterName = "# appointments processed";
totalAppointments.CounterHelp = "Total number of appointments processed.";
totalAppointments.CounterType = PerformanceCounterType.NumberOfItems32;
counters.Add(totalAppointments);
// 2. counter for counting operations per second:
// PerformanceCounterType.RateOfCountsPerSecond32
var appointmentsPerSecond = new CounterCreationData();
appointmentsPerSecond.CounterName = "# appointments / sec";
appointmentsPerSecond.CounterHelp = "Number of operations executed per second";
appointmentsPerSecond.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;
counters.Add(appointmentsPerSecond);
// create new category with the counters above
PerformanceCounterCategory.Create("nHydrate", "nHydrate Category", counters);
}
}
开发者ID:nHydrate,项目名称:nHydrate,代码行数:26,代码来源:PerformanceCounterHelper.cs
示例16: AddRange
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public void AddRange(CounterCreationData[] value) {
if (value == null) {
throw new ArgumentNullException("value");
}
for (int i = 0; ((i) < (value.Length)); i = ((i) + (1))) {
this.Add(value[i]);
}
}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:11,代码来源:CounterCreationDataCollection.cs
示例17: CreateCategory
void CreateCategory(CounterCreationData[] counters)
{
PerformanceCounterCategory.Create(
_categoryName,
_categoryHelp,
PerformanceCounterCategoryType.MultiInstance,
new CounterCreationDataCollection(counters));
}
开发者ID:MassTransit,项目名称:MassTransit,代码行数:8,代码来源:BaseWindowsPerformanceCounters.cs
示例18: CreateCountingCounterCreationData
private static CounterCreationData CreateCountingCounterCreationData(string counterName, string counterHelp)
{
CounterCreationData totalOps = new CounterCreationData();
totalOps.CounterName = counterName;
totalOps.CounterHelp = counterHelp;
totalOps.CounterType = PerformanceCounterType.NumberOfItems32;
return totalOps;
}
开发者ID:jondhinkle,项目名称:Rock,代码行数:8,代码来源:SampledStatisticsImpl.cs
示例19: PerformanceCounterManager
/// <summary>
/// Initializes a new instance of the <see cref="PerformanceCounterManager" /> class.
/// </summary>
/// <param name="categoryInfo">The category information.</param>
/// <param name="counterDefinitions">The counter definitions.</param>
protected PerformanceCounterManager(PerformanceCounterCategoryInfo categoryInfo, CounterCreationData[] counterDefinitions)
{
var category = GetOrCreateCounterCategory(categoryInfo, counterDefinitions);
foreach (var counter in category.GetCounters())
{
counter.ReadOnly = false;
_counterMap.Add(counter.CounterName, new SafePerformanceCounter(counter));
}
}
开发者ID:bradsjm,项目名称:DotEmwin,代码行数:14,代码来源:PerformanceCounterManager.cs
示例20: AddCounterToCollection
public void AddCounterToCollection(CounterCreationDataCollection counterData)
{
CounterCreationData counterCreationData = new CounterCreationData(
_counterName,
_counterHelp,
_pcType);
counterData.Add(counterCreationData);
}
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:9,代码来源:STPPerformanceCounter.cs
注:本文中的System.Diagnostics.CounterCreationData类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论