当前位置: 首页>>代码示例>>C#>>正文


C# CounterCreationDataCollection.Add方法代码示例

本文整理汇总了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);
        }
开发者ID:shushengli,项目名称:azure-sdk-for-media-services,代码行数:29,代码来源:InstallperfCountersPlugin.cs

示例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);
            }
        }
开发者ID:shukanov-artyom,项目名称:studies,代码行数:27,代码来源:Program.cs

示例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);
        }
开发者ID:thefringeninja,项目名称:Event-handling,代码行数:27,代码来源:WMIQueueProcessorInstrumentation.cs

示例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);
            }
        }
开发者ID:ngbrown,项目名称:EasyNetQ,代码行数:33,代码来源:PerformanceCounterSpike.cs

示例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();

		}
开发者ID:davelondon,项目名称:dontstayin,代码行数:35,代码来源:Program.cs

示例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)
            };
        }
开发者ID:shukanov-artyom,项目名称:studies,代码行数:32,代码来源:MainWindow.xaml.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: 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

示例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);
			}

		}
开发者ID:nHydrate,项目名称:nHydrate,代码行数:26,代码来源:PerformanceCounterHelper.cs

示例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;
            }
        }
开发者ID:Stoom,项目名称:WebSocketListener,代码行数:59,代码来源:PerformanceCounters.cs

示例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();
        }
开发者ID:greeduomacro,项目名称:divinity,代码行数:56,代码来源:SaveMetrics.cs

示例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);
			}
		}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:12,代码来源:PerfCounterManager.cs

示例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);

            //}
        }
开发者ID:kainhong,项目名称:CurrencyStore,代码行数:55,代码来源:ServerInstrumentation.cs

示例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);
        }
开发者ID:Rejendo,项目名称:orleans,代码行数:52,代码来源:TelemetryContext.cs

示例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);
            }
        }
开发者ID:KroneckerX,项目名称:WCell,代码行数:52,代码来源:Program.cs


注:本文中的System.Diagnostics.CounterCreationDataCollection.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。