本文整理汇总了C#中System.Diagnostics.CounterCreationDataCollection类的典型用法代码示例。如果您正苦于以下问题:C# CounterCreationDataCollection类的具体用法?C# CounterCreationDataCollection怎么用?C# CounterCreationDataCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CounterCreationDataCollection类属于System.Diagnostics命名空间,在下文中一共展示了CounterCreationDataCollection类的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: 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
示例3: CreateOutboundCategory
private static void CreateOutboundCategory()
{
if (PerformanceCounterCategory.Exists(OutboundPerfomanceCounters.CATEGORY))
{
logger.DebugFormat("Deleting existing performance counter category '{0}'.", OutboundPerfomanceCounters.CATEGORY);
PerformanceCounterCategory.Delete(OutboundPerfomanceCounters.CATEGORY);
}
logger.DebugFormat("Creating performance counter category '{0}'.", OutboundPerfomanceCounters.CATEGORY);
try
{
var counters = new CounterCreationDataCollection(OutboundPerfomanceCounters.SupportedCounters().ToArray());
PerformanceCounterCategory.Create(
OutboundPerfomanceCounters.CATEGORY,
"Provides statistics for Rhino-Queues messages out-bound from the current machine.",
PerformanceCounterCategoryType.MultiInstance,
counters);
}
catch (Exception ex)
{
logger.Error("Creation of outbound counters failed.", ex);
throw;
}
}
开发者ID:hibernating-rhinos,项目名称:rhino-queues,代码行数:25,代码来源:PerformanceCategoryCreator.cs
示例4: Test
public void Test()
{
const string categoryName = "TestCategory";
const string categoryHelp = "Test category help";
const PerformanceCounterCategoryType categoryType = PerformanceCounterCategoryType.SingleInstance;
const string counterName = "TestElapsedTime";
const string counterHelp = "Test elapsed time";
if (!PerformanceCounterCategory.Exists(categoryName))
{
var counterCreationData = new CounterCreationDataCollection(ElapsedTime.CounterCreator.CreateCounterData(counterName, counterHelp));
var category = PerformanceCounterCategory.Create(categoryName, categoryHelp, categoryType, counterCreationData);
}
var elapsedTime = new ElapsedTime(PerformanceCounterFactory.Singleton, categoryName, "TestElapsedTime", false);
elapsedTime.Reset();
var count = 0;
while (++count < 10)
{
Thread.Sleep(1000);
var value = elapsedTime.NextValue();
Debug.Print("Value = {0}", value);
}
elapsedTime.Dispose();
PerformanceCounterCategory.Delete(categoryName);
}
开发者ID:rob-blackbourn,项目名称:JetBlack.Diagnostics,代码行数:28,代码来源:ElapsedTimeFixture.cs
示例5: 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
示例6: 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
示例7: Create
internal static void Create()
{
if (PerformanceCounterCategory.Exists(engineCategory))
{
PerformanceCounterCategory.Delete(engineCategory);
}
var counterList = new CounterCreationDataCollection();
counterList.Add(new CounterCreationData(
dirtyNodeEventCount,
"Describes the number of dirty node messages on the engine's event queue.",
PerformanceCounterType.NumberOfItems32));
counterList.Add(new CounterCreationData(
calculatedNodeCount,
"Describes the number of items scheduled for calculation by an engine task.",
PerformanceCounterType.NumberOfItems32));
counterList.Add(new CounterCreationData(
taskExecutionTime,
@"Describes the time in milliseconds to process an engine task.",
PerformanceCounterType.NumberOfItems32));
PerformanceCounterCategory.Create(
engineCategory,
"Engine counters",
PerformanceCounterCategoryType.SingleInstance,
counterList);
}
开发者ID:filipek,项目名称:SmartGraph,代码行数:30,代码来源:EngineCounters.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: 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
示例10: 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
示例11: 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
示例12: PerformanceCounters
static PerformanceCounters()
{
try
{
if (PerformanceCounterCategory.Exists(category))
PerformanceCounterCategory.Delete(category);
// order to be sure that *Base follows counter
var props = typeof(PerformanceCounters).GetProperties().OrderBy(p => p.Name).ToList();
var counterCollection = new CounterCreationDataCollection();
foreach (var p in props)
{
var attr = (PerformanceCounterTypeAttribute)p.GetCustomAttributes(typeof(PerformanceCounterTypeAttribute), true).First();
counterCollection.Add(new CounterCreationData() { CounterName = p.Name, CounterHelp = string.Empty, CounterType = attr.Type });
}
PerformanceCounterCategory.Create(category, "Online Trainer Perf Counters", PerformanceCounterCategoryType.MultiInstance, counterCollection);
}
catch (Exception e)
{
new TelemetryClient().TrackException(e);
}
}
开发者ID:G453,项目名称:vowpal_wabbit,代码行数:25,代码来源:PerformanceCounters.cs
示例13: 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
示例14: 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
示例15: 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
示例16: InstallCounters
public static bool InstallCounters()
{
string message = String.Empty;
try
{
if(RelayNode.log.IsInfoEnabled)
RelayNode.log.InfoFormat("Creating performance counter category {0}", RelayNodeCounters.PerformanceCategoryName);
Console.WriteLine("Creating performance counter category " + RelayNodeCounters.PerformanceCategoryName);
CounterCreationDataCollection counterDataCollection = new CounterCreationDataCollection();
for (int i = 0; i < RelayNodeCounters.PerformanceCounterNames.Length; i++)
{
counterDataCollection.Add(new CounterCreationData(RelayNodeCounters.PerformanceCounterNames[i], RelayNodeCounters.PerformanceCounterHelp[i], RelayNodeCounters.PerformanceCounterTypes[i]));
message = "Creating perfomance counter " + RelayNodeCounters.PerformanceCounterNames[i];
Console.WriteLine(message);
if(RelayNode.log.IsInfoEnabled)
RelayNode.log.Info(message);
}
PerformanceCounterCategory.Create(RelayNodeCounters.PerformanceCategoryName, "Counters for the MySpace Data Relay", PerformanceCounterCategoryType.MultiInstance, counterDataCollection);
return true;
}
catch (Exception ex)
{
message = "Error creating Perfomance Counter Category " + RelayNodeCounters.PerformanceCategoryName + ": " + ex.ToString() + ". Counter category will not be used.";
Console.WriteLine(message);
if (RelayNode.log.IsErrorEnabled)
RelayNode.log.Error(message);
return false;
}
}
开发者ID:edwardt,项目名称:MySpace-Data-Relay,代码行数:35,代码来源:CounterInstaller.cs
示例17: CreatePerformanceCounters
private static bool CreatePerformanceCounters()
{
if (!PerformanceCounterCategory.Exists("MyCategory"))
{
var counters =
new CounterCreationDataCollection
{
new CounterCreationData(
"# operations executed",
"Total number of operations executed",
PerformanceCounterType.NumberOfItems32),
new CounterCreationData(
"# operations / sec",
"Number of operations executed per second",
PerformanceCounterType.RateOfCountsPerSecond32)
};
PerformanceCounterCategory.Create("MyCategory",
"Sample category for Codeproject", counters);
return true;
}
return false;
}
开发者ID:rrsc,项目名称:ProgrammingInCSharp,代码行数:25,代码来源:CreatingAPerformanceCounter.cs
示例18: createDefaultReporter
public static SyntheticCountersReporter createDefaultReporter(Logger _log, ICounterSamplingConfiguration counterSamplingConfig)
{
string signalFxCategory = "SignalFX";
try
{
System.Diagnostics.CounterCreationDataCollection CounterDatas =
new System.Diagnostics.CounterCreationDataCollection();
createCounterIfNotExist(signalFxCategory, "UsedMemory", "Total used memory", System.Diagnostics.PerformanceCounterType.NumberOfItems64, CounterDatas);
if (CounterDatas.Count != 0)
{
System.Diagnostics.PerformanceCounterCategory.Create(
signalFxCategory, "SignalFx synthetic counters.",
System.Diagnostics.PerformanceCounterCategoryType.SingleInstance, CounterDatas);
}
}
catch (Exception e)
{
_log.Info(e.ToString());
return null;
}
SyntheticCountersReporter reporter = new SyntheticCountersReporter(counterSamplingConfig);
reporter._sfxCountersUpdateMethods.Add("UsedMemory", updateUsedMemoryCounter);
return reporter;
}
开发者ID:BitBuster,项目名称:PerfCounterReporter,代码行数:28,代码来源:SyntheticCountersReporter.cs
示例19: 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
示例20: InstrumentationManager
protected InstrumentationManager(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType)
{
_categoryName = categoryName;
_categoryHelp = categoryHelp;
_categoryType = categoryType;
_counterDefinitions = new CounterCreationDataCollection();
}
开发者ID:Rejendo,项目名称:orleans,代码行数:7,代码来源:InstrumentationManager.cs
注:本文中的System.Diagnostics.CounterCreationDataCollection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论