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


C# PerformanceCounter.Increment方法代码示例

本文整理汇总了C#中System.Diagnostics.PerformanceCounter.Increment方法的典型用法代码示例。如果您正苦于以下问题:C# PerformanceCounter.Increment方法的具体用法?C# PerformanceCounter.Increment怎么用?C# PerformanceCounter.Increment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Diagnostics.PerformanceCounter的用法示例。


在下文中一共展示了PerformanceCounter.Increment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            if (CreatePerformanecCounters())
            {
                Console.WriteLine("Created performance counters");
                Console.WriteLine("Please restart the application");
                Console.ReadKey();

                return;
            }

            var totalOperationsCounter = new PerformanceCounter(
                "MyCategory",
                "# operations executed",
                "",
                false);
            var operationsPerSecondCounter = new PerformanceCounter(
                "MyCategory",
                "# operations sec",
                "",
                false);

            totalOperationsCounter.Increment();
            operationsPerSecondCounter.Increment();
        }
开发者ID:jbijoux,项目名称:Exam70_483,代码行数:25,代码来源:Program.cs

示例2: IncreaseCounter

 protected void IncreaseCounter(object sender, EventArgs e)
 {
     using (var counter = new PerformanceCounter("Test Category", "Test Increment", readOnly: false))
     {
         counter.Increment();
     }
 }
开发者ID:jeremychild,项目名称:litemedia-alive,代码行数:7,代码来源:Index.aspx.cs

示例3: UpdateCounterConditional

 private void UpdateCounterConditional(PerformanceCounter c, CounterInvokeDirection expectedDirection)
 {
     if (c != null && (expectedDirection & _direction) == expectedDirection)
     {
         lock (c)
         {
             //reset name
             string ins = c.InstanceName;
             c.Increment();
             //also update overall insance!
             c.InstanceName = OverallInstance;
             c.Increment();
             c.InstanceName = ins;
         }
     }
 }
开发者ID:jzi96,项目名称:PostsharpAspectsLibrary,代码行数:16,代码来源:RatePerformanceCounterAttribute.cs

示例4: btnCount_Click

        private void btnCount_Click(object sender, RoutedEventArgs e)
        {
            if(!PerformanceCounterCategory.Exists("PerfApp"))
            {
                PerformanceCounterCategory.Create("PerfApp", "Conters for app", PerformanceCounterCategoryType.SingleInstance, "Clicks", "Times the user has clicked the button");
            }

            PerformanceCounter pc = new PerformanceCounter("PerfApp", "Clicks", false);
            pc.Increment();
            txbCounter.Content = pc.NextValue().ToString();
        }
开发者ID:Rafael-Miceli,项目名称:ProjectStudiesCert70-536,代码行数:11,代码来源:MainWindow.xaml.cs

示例5: WriteCounters

		public void WriteCounters ()
		{
			using (var hitCounter = new PerformanceCounter ("Category", "Hits")) {
				using (var rateCounter = new PerformanceCounter ("Category", "Rate")) {
					for (var x = 0; x < 5; x++) {
						hitCounter.Increment ();
						rateCounter.IncrementBy (x + 10);
					}
				}
			}
		}
开发者ID:caloggins,项目名称:DOT-NET-on-Linux,代码行数:11,代码来源:PerformanceEncounterExample.cs

示例6: Increment

 public static void Increment()
 {
     if (_exists)
     {
         using (var counter = new PerformanceCounter(_category, _counter, false)
                                  {
                                      MachineName = "."
                                  })
         {
             counter.Increment();
         }
     }
 }
开发者ID:KarlDirck,项目名称:cavity,代码行数:13,代码来源:CommandCounter.cs

示例7: IncrementCounter

        static void IncrementCounter()
        {
            // get an instance of our perf counter
            PerformanceCounter counter = new PerformanceCounter();
            counter.CategoryName = "MyCategory";
            counter.CounterName = "AddCounter";
            counter.ReadOnly = false;

            // increment and close the perf counter
            counter.Increment();

            counter.Close();
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:13,代码来源:client.cs

示例8: Run

        public override void Run()
        {
            while (true)
            {
                using (var counter = new PerformanceCounter("category", "counter1", false))
                {
                    counter.Increment();
                }

                EventLog.WriteEntry("source", "running");

                Thread.Sleep(1000);
            }
        }
开发者ID:peterhholroyd,项目名称:fmg_dhc,代码行数:14,代码来源:WorkerRole.cs

示例9: SaveMetrics

		public SaveMetrics()
		{
			if (!PerformanceCounterCategory.Exists(PerformanceCategoryName))
			{
				var counters = new CounterCreationDataCollection
				{
					new CounterCreationData(
						//
						"Save - Count", "Number of world saves.", PerformanceCounterType.NumberOfItems32),
					new CounterCreationData(
						//
						"Save - Items/sec", "Number of items saved per second.", PerformanceCounterType.RateOfCountsPerSecond32),
					new CounterCreationData(
						//
						"Save - Mobiles/sec", "Number of mobiles saved per second.", PerformanceCounterType.RateOfCountsPerSecond32),
					new CounterCreationData(
						//
						"Save - Customs/sec", "Number of cores saved per second.", PerformanceCounterType.RateOfCountsPerSecond32),
					new CounterCreationData(
						//
						"Save - Serialized bytes/sec",
						"Amount of world-save bytes serialized per second.",
						PerformanceCounterType.RateOfCountsPerSecond32),
					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);
			dataPerSecond = new PerformanceCounter(PerformanceCategoryName, "Save - Customs/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:zerodowned,项目名称:JustUO-merged-with-EC-Support,代码行数:48,代码来源:SaveMetrics.cs

示例10: Main

        static void Main(string[] args)
        {
            CounterCreationDataCollection counters = new CounterCreationDataCollection();
            counters.Add(new CounterCreationData("Sales", "Number of total sales", PerformanceCounterType.NumberOfItems64));
            counters.Add(new CounterCreationData("Active Users", "Number of active users", PerformanceCounterType.NumberOfItems64));
            counters.Add(new CounterCreationData("Sales value", "Total value of all sales", PerformanceCounterType.NumberOfItems64));
            PerformanceCounterCategory.Create("MyApp Counters", "Counters describing the performance of MyApp",
                PerformanceCounterCategoryType.SingleInstance, counters);

            PerformanceCounter pc = new PerformanceCounter("MyApp Counters", "Sales", false);

            pc.RawValue = 7;
            pc.Decrement();
            pc.Increment();
            pc.IncrementBy(3);
        }
开发者ID:oblivious,项目名称:Oblivious,代码行数:16,代码来源:Program.cs

示例11: Sample_CreatingPerformanceCounter

        //
        // http://msdn.microsoft.com/en-us/library/5e3s61wf(v=vs.90).aspx
        //
        private static void Sample_CreatingPerformanceCounter()
        {
            var performanceMonitor = new PerformanceMonitor();
            performanceMonitor.AddCounter("CustomInstance");
            using (var counter = new PerformanceCounter(PerformanceMonitor.pcCategory, "CustomInstance", readOnly: false))
            {
                string command;
                do
                {
                    counter.Increment();
                    Console.Write("enter command: ");
                    command = Console.ReadLine();
                } while (command != "");
            }

            Console.WriteLine("press any key...");
            Console.ReadKey();
        }
开发者ID:constructor-igor,项目名称:TechSugar,代码行数:21,代码来源:Program.cs

示例12: IncrementUnhandledExceptions

        private static void IncrementUnhandledExceptions()
        {
            try
            {
                string performanceCounterCategory = Assembly.GetEntryAssembly().GetName().Name;
                string performanceCounterName = "UnhandledExceptions";

                PerformanceCounter counter = new PerformanceCounter();
                counter.CategoryName = performanceCounterCategory;
                counter.CounterName = performanceCounterName;
                counter.ReadOnly = false;
                counter.Increment();
                counter.Close();
            }
            catch (Exception)
            {
                return;
            }
        }
开发者ID:wmccullough,项目名称:ServiceFX,代码行数:19,代码来源:HostConfiguratorExtensions.cs

示例13: Main

        public static void Main(string[] args)
        {
            if (CreatePerformanceCounters())
            {
                Console.WriteLine("Created performance counters");
                Console.WriteLine("Please restart application");
                Console.ReadKey();
                return;
            }

            var totalOperationsCounter = new PerformanceCounter("MyCategory", "# operations executed", "", false);
            var operationsPerSecondCounter = new PerformanceCounter("MyCategory", "# operations / sec", "", false);

            totalOperationsCounter.Increment();
            operationsPerSecondCounter.Increment();

            Console.WriteLine("Total number of operations: {0}", totalOperationsCounter.RawValue);
            Console.WriteLine("Operations / sec: {0}", operationsPerSecondCounter.RawValue);

            Console.ReadLine();
        }
开发者ID:nissbran,项目名称:Training-Certifications,代码行数:21,代码来源:Program.cs

示例14: StopCounter

        public void StopCounter()
        {
            this.stopWatch.Stop();

            using (
                var averageExecutionTimeCounter = new PerformanceCounter(Category, 
                                                                         AverageExecutionTimeCounterName, 
                                                                         this.instanceName, 
                                                                         false))
            {
                using (
                    var averageExecutionTimeBaseCounter = new PerformanceCounter(Category, 
                                                                                 AverageExecutionTimeBaseCounterName, 
                                                                                 this.instanceName, 
                                                                                 false))
                {
                    averageExecutionTimeCounter.IncrementBy(this.stopWatch.ElapsedTicks);
                    averageExecutionTimeBaseCounter.Increment();
                }
            }
        }
开发者ID:luxbet,项目名称:SS.Integration.Adapter,代码行数:21,代码来源:TimePerformanceCounter.cs

示例15:

 //public static void CountBeginAverageTimerCounter
 //                        (
 //                            this PerformanceCounter performanceCounter
 //                            , PerformanceCounter basePerformanceCounter
 //                            , Stopwatch stopwatch
 //                        )
 //{
 //        //stopwatch.Reset();
 //        //stopwatch.Start();
 //        stopwatch.Restart();
 //}
 public static void CountEndAverageTimerCounter
                 (
                     this PerformanceCounter performanceCounter
                     , PerformanceCounter basePerformanceCounter
                     , Stopwatch stopwatch
                     , Func<PerformanceCounterProcessingFlagsType, PerformanceCounter, long> onBasePerformanceCounterChangeValueProcessFunc = null
                 )
 {
     if
         (
             stopwatch != null
         )
     {
         if (stopwatch.IsRunning)
         {
             stopwatch.Stop();
         }
         performanceCounter
                 .IncrementBy(stopwatch.ElapsedTicks);
         //stopwatch = null;
         var increment = 1L;
         if (onBasePerformanceCounterChangeValueProcessFunc != null)
         {
             increment = onBasePerformanceCounterChangeValueProcessFunc
                                 (
                                     PerformanceCounterProcessingFlagsType.TimeBasedOnEnd
                                     , basePerformanceCounter
                                 );
         }
         if (increment == 1)
         {
             basePerformanceCounter.Increment();
         }
         else
         {
             basePerformanceCounter.IncrementBy(increment);
         }
         
     }
 }
开发者ID:Microshaoft,项目名称:Microshaoft.Common.Utilities.Net.4x,代码行数:51,代码来源:PerformanceCounterExtensionMethodsManager.cs


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