Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Real Time Performance Monitoring in a Console task

$
0
0

Im sorry that I dont know C# but I don't. But I do have a disk performance monitor that I got off the net that I need translated to VB.

The monitor was found at: 

http://social.msdn.microsoft.com/Forums/vstudio/en-US/37b8b63a-da32-4497-b570-3811a2255dee/how-to-get-disk-io-countersdisk-write-time-disk-read-time-using-cnet?forum=csharplanguage

And it looks like this:

private PerformanceCounter cpuPerformanceCounter = new PerformanceCounter(); 
private PerformanceCounter memoryPerformanceCounter = new PerformanceCounter(); 
private PerformanceCounter diskReadsPerformanceCounter = new PerformanceCounter(); 
private PerformanceCounter diskWritesPerformanceCounter = new PerformanceCounter(); 
private PerformanceCounter diskTransfersPerformanceCounter = new PerformanceCounter();  
 
private void buttonStartPerformanceLogging_Click(object sender, EventArgs e) 
        { 
            InitPerformanceCounters(); // This can be put in class constructor also.. 
            this.timerForPerformanceData.Enabled = true
        } 
 
        private void timerForPerformanceData_Tick(object sender, EventArgs e) 
        { 
            PrintPerformanceData(); 
        } 
 
        private void InitPerformanceCounters() 
        { 
            this.cpuPerformanceCounter.CategoryName = "Processor"
            this.cpuPerformanceCounter.CounterName = "% Processor Time"
            this.cpuPerformanceCounter.InstanceName = "_Total"
 
            this.memoryPerformanceCounter.CategoryName = "Memory"
            this.memoryPerformanceCounter.CounterName = "Available MBytes"
 
            this.diskReadsPerformanceCounter.CategoryName = "PhysicalDisk"
            this.diskReadsPerformanceCounter.CounterName = "Disk Reads/sec"
            this.diskReadsPerformanceCounter.InstanceName = "_Total"
 
            this.diskWritesPerformanceCounter.CategoryName = "PhysicalDisk"
            this.diskWritesPerformanceCounter.CounterName = "Disk Writes/sec"
            this.diskWritesPerformanceCounter.InstanceName = "_Total"
 
            this.diskTransfersPerformanceCounter.CategoryName = "PhysicalDisk"
            this.diskTransfersPerformanceCounter.CounterName = "Disk Transfers/sec"
            this.diskTransfersPerformanceCounter.InstanceName = "_Total"
        } 
 
        private void PrintPerformanceData() 
        { 
            string currentCpuUsage = "CPU Usage : " + this.cpuPerformanceCounter.NextValue().ToString() + " %" + Environment.NewLine; 
            string currentMemoryUsage = "Memory Usage : " + this.memoryPerformanceCounter.NextValue().ToString() + " Mb" + Environment.NewLine; 
            string currentDiskReads = "Disk reads / sec : " + this.diskReadsPerformanceCounter.NextValue().ToString() + Environment.NewLine; 
            string currentDiskWrites = "Disk writes / sec : " + this.diskWritesPerformanceCounter.NextValue().ToString() + Environment.NewLine; 
            string currentDiskTransfers = "Disk transfers / sec : " + this.diskTransfersPerformanceCounter.NextValue().ToString() + Environment.NewLine; 
 
            Console.Write("{0}{1}{2}{3}{4}", currentCpuUsage, currentMemoryUsage, currentDiskReads, currentDiskWrites, currentDiskTransfers); 

        }  

Please help me....

Renee


"MODERN PROGRAMMING is deficient in elementary ways BECAUSE of problems INTRODUCED by MODERN PROGRAMMING." Me


Viewing all articles
Browse latest Browse all 31927

Latest Images

Trending Articles



Latest Images

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