Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Where to find the performance counter information?

$
0
0

Code:

 class Program
    {
        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 operationPerSecondCounter = new PerformanceCounter("MyCategory","# operations / sec","",
                false);
            totalOperationsCounter.Increment();
            operationPerSecondCounter.Increment();
        }

        private static bool CreatePerformanceCounters()
        {
            if(!PerformanceCounterCategory.Exists("MyCategory"))
            {
                CounterCreationDataCollection 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;
        }
    }
After running it, it displays two line information on the screen. But where is the location to store these information? I want to look at it.


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>