本文整理汇总了C#中System.Diagnostics.CounterCreationDataCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# CounterCreationDataCollection.Add方法的具体用法?C# CounterCreationDataCollection.Add怎么用?C# CounterCreationDataCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.CounterCreationDataCollection
的用法示例。
在下文中一共展示了CounterCreationDataCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: 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);
}
}
示例3: 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);
}
示例4: 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);
}
}
示例5: 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();
}
示例6: 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)
};
}
示例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);
}
示例8: 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());
}
}
示例9: 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);
}
}
示例10: CreatePerformanceCounters
public static bool CreatePerformanceCounters()
{
string categoryName = "WebSocketListener_Test";
if (!PerformanceCounterCategory.Exists(categoryName))
{
var ccdc = new CounterCreationDataCollection();
ccdc.Add(new CounterCreationData
{
CounterType = PerformanceCounterType.RateOfCountsPerSecond64,
CounterName = pflabel_msgIn
});
ccdc.Add(new CounterCreationData
{
CounterType = PerformanceCounterType.RateOfCountsPerSecond64,
CounterName = pflabel_msgOut
});
ccdc.Add(new CounterCreationData
{
CounterType = PerformanceCounterType.NumberOfItems64,
CounterName = pflabel_connected
});
ccdc.Add(new CounterCreationData
{
CounterType = PerformanceCounterType.AverageTimer32,
CounterName = pflabel_delay
});
ccdc.Add(new CounterCreationData
{
CounterType = PerformanceCounterType.AverageBase,
CounterName = pflabel_delay + " base"
});
PerformanceCounterCategory.Create(categoryName, "", PerformanceCounterCategoryType.SingleInstance, ccdc);
Console.WriteLine("Performance counters have been created, please re-run the app");
return true;
}
else
{
//PerformanceCounterCategory.Delete(categoryName);
//Console.WriteLine("Delete");
//return true;
MessagesIn = new PerformanceCounter(categoryName, pflabel_msgIn, false);
MessagesOut = new PerformanceCounter(categoryName, pflabel_msgOut, false);
Connected = new PerformanceCounter(categoryName, pflabel_connected, false);
Delay = new PerformanceCounter(categoryName, pflabel_delay, false);
DelayBase = new PerformanceCounter(categoryName, pflabel_delay + " base", false);
Connected.RawValue = 0;
return false;
}
}
示例11: SaveMetrics
public SaveMetrics()
{
if ( !PerformanceCounterCategory.Exists( PerformanceCategoryName ) ) {
CounterCreationDataCollection counters = new CounterCreationDataCollection();
counters.Add( new CounterCreationData(
"Save - Count",
"Number of world saves.",
PerformanceCounterType.NumberOfItems32
)
);
counters.Add( new CounterCreationData(
"Save - Items/sec",
"Number of items saved per second.",
PerformanceCounterType.RateOfCountsPerSecond32
)
);
counters.Add( new CounterCreationData(
"Save - Mobiles/sec",
"Number of mobiles saved per second.",
PerformanceCounterType.RateOfCountsPerSecond32
)
);
counters.Add( new CounterCreationData(
"Save - Serialized bytes/sec",
"Amount of world-save bytes serialized per second.",
PerformanceCounterType.RateOfCountsPerSecond32
)
);
counters.Add( new CounterCreationData(
"Save - Written bytes/sec",
"Amount of world-save bytes written to disk per second.",
PerformanceCounterType.RateOfCountsPerSecond32
)
);
#if !MONO
PerformanceCounterCategory.Create( PerformanceCategoryName, PerformanceCategoryDesc, PerformanceCounterCategoryType.SingleInstance, counters );
#endif
}
numberOfWorldSaves = new PerformanceCounter( PerformanceCategoryName, "Save - Count", false );
itemsPerSecond = new PerformanceCounter( PerformanceCategoryName, "Save - Items/sec", false );
mobilesPerSecond = new PerformanceCounter( PerformanceCategoryName, "Save - Mobiles/sec", false );
serializedBytesPerSecond = new PerformanceCounter( PerformanceCategoryName, "Save - Serialized bytes/sec", false );
writtenBytesPerSecond = new PerformanceCounter( PerformanceCategoryName, "Save - Written bytes/sec", false );
// increment number of world saves
numberOfWorldSaves.Increment();
}
示例12: CheckAndCreateCategory
private void CheckAndCreateCategory()
{
if (!System.Diagnostics.PerformanceCounterCategory.Exists(CATEGORY))
{
CounterCreationDataCollection counters =
new CounterCreationDataCollection();
counters.Add(GetCacheHitCounterData());
counters.Add(GetCachedInstancesCounterData());
PerformanceCounterCategory.Create(
CATEGORY, CATEGORY_DESCRIPTION, counters);
}
}
示例13: SetupCategory
/// <summary>
///
/// </summary>
public static void SetupCategory()
{
RemoveCategory();
//if (!PerformanceCounterCategory.Exists(CATEGORY_NAME)) {
CounterCreationDataCollection CCDC = new CounterCreationDataCollection();
CounterCreationData a = new CounterCreationData();
a.CounterType = PerformanceCounterType.NumberOfItems32;
a.CounterName = "Connected";
CCDC.Add(a);
//CounterCreationData b = new CounterCreationData();
//b.CounterType = PerformanceCounterType.NumberOfItems64;
//b.CounterName = "Disconneted";
//CCDC.Add(b);
CounterCreationData c = new CounterCreationData();
c.CounterType = PerformanceCounterType.NumberOfItems64;
c.CounterName = "Fault Count";
CCDC.Add(c);
CounterCreationData d1 = new CounterCreationData();
d1.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;
d1.CounterName = "Produce/sec";
CCDC.Add(d1);
CounterCreationData d2 = new CounterCreationData();
d2.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;
d2.CounterName = "Process/sec";
CCDC.Add(d2);
CounterCreationData d3 = new CounterCreationData();
d3.CounterType = PerformanceCounterType.NumberOfItems64;
d3.CounterName = "Login Failed";
CCDC.Add(d3);
CounterCreationData d4 = new CounterCreationData();
d4.CounterType = PerformanceCounterType.NumberOfItems64;
d4.CounterName = "Unregisted";
CCDC.Add(d4);
CounterCreationData d5 = new CounterCreationData();
d5.CounterType = PerformanceCounterType.NumberOfItems32;
d5.CounterName = "Queue length";
CCDC.Add(d5);
PerformanceCounterCategory.Create(CATEGORY_NAME, NAME,
PerformanceCounterCategoryType.MultiInstance, CCDC);
//}
}
示例14: Create
public static void Create()
{
if (PerformanceCounterCategory.Exists(CategoryName))
PerformanceCounterCategory.Delete(CategoryName);
CounterCreationDataCollection ccdc = new CounterCreationDataCollection();
ccdc.Add(
new CounterCreationData()
{
CounterType = PerformanceCounterType.NumberOfItems32,
CounterName = "Open Connections",
CounterHelp = string.Empty
});
ccdc.Add(
new CounterCreationData()
{
CounterType = PerformanceCounterType.NumberOfItems32,
CounterName = "Writes Outstanding",
CounterHelp = string.Empty
});
ccdc.Add(
new CounterCreationData()
{
CounterType = PerformanceCounterType.NumberOfItems32,
CounterName = "Writes Total",
CounterHelp = string.Empty
});
ccdc.Add(
new CounterCreationData()
{
CounterType = PerformanceCounterType.NumberOfItems32,
CounterName = "Writes Posted Total",
CounterHelp = string.Empty
});
ccdc.Add(
new CounterCreationData()
{
CounterType = PerformanceCounterType.NumberOfItems32,
CounterName = "Writes Posted Failures",
CounterHelp = string.Empty
});
ccdc.Add(
new CounterCreationData()
{
CounterType = PerformanceCounterType.NumberOfItems32,
CounterName = "Sql Transient Errors",
CounterHelp = string.Empty
});
// Create the category.
PerformanceCounterCategory.Create(CategoryName, string.Empty, PerformanceCounterCategoryType.SingleInstance, ccdc);
}
示例15: SetupCounters
public static void SetupCounters()
{
var counterList = new CounterCreationDataCollection();
var sentPacketCounter = new CounterCreationData
{
CounterName = "Packets Sent/sec",
CounterType = PerformanceCounterType.RateOfCountsPerSecond64,
CounterHelp = "Number of packets sent per second."
};
var recvPacketCounter = new CounterCreationData
{
CounterName = "Packets Received/sec",
CounterType = PerformanceCounterType.RateOfCountsPerSecond64,
CounterHelp = "Number of packets received per second."
};
var bytesSentCounter = new CounterCreationData
{
CounterName = "Bytes Sent",
CounterType = PerformanceCounterType.NumberOfItems64,
CounterHelp = "Total number of bytes sent."
};
var bytesRecvCounter = new CounterCreationData
{
CounterName = "Bytes Received",
CounterType = PerformanceCounterType.NumberOfItems64,
CounterHelp = "Total number of bytes received."
};
var authQueueCounter = new CounterCreationData
{
CounterName = "Auth Queue Size",
CounterType = PerformanceCounterType.CountPerTimeInterval32,
CounterHelp = "Number of clients waiting in the auth queue."
};
counterList.Add(sentPacketCounter);
counterList.Add(recvPacketCounter);
counterList.Add(bytesSentCounter);
counterList.Add(bytesRecvCounter);
counterList.Add(authQueueCounter);
if (!PerformanceCounterCategory.Exists(CategoryName))
{
PerformanceCounterCategory.Create(CategoryName, CategoryHelp,
PerformanceCounterCategoryType.SingleInstance,
counterList);
}
}