By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,627 Members | 2,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,627 IT Pros & Developers. It's quick & easy.

How to find out how many instances are running and the current CPU usage rate.

P: n/a
I want to check chose performance related parameters in my code.
Thanks!
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Performance counters may be what you are looking for. You can run
perfmon(jsut go to the start menu then run and type "perfmon" and hit
enter) to view all of the available performance counters on your machine.
Click the + icon in the toolbar to add other performance counters to the
view.

In the .Net Framework we have a class called PerformanceCounter in the
Diagnostics namespace. This type allows you to access all of the
performance counters that you can view in perfmon. If you wanted the %CPU
you would do something like the following:

PerformanceCounter percentCpu = new PerformanceCounter("Processor", "%
Processor Time", "_Total");

while(true) {
Console.WriteLine("% CPU:{0}", percentCpu.NextValue())
System.Threading.Thread.Sleep(1000);
}

See the following link on MSDN for more information:
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdiagnosticsperformancecounterclasstopic .asp

Ryan Byington [MS]
This posting is provided "AS IS" with no warranties, and confers no
rights.Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--------------------
From: "davidw" <wy*****@hotmail.com>
Subject: How to find out how many instances are running and the current CPU usage rate.Date: Thu, 24 Jul 2003 12:17:37 -0700
Lines: 6
Organization: Affinisys Inc.
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <ul**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.general
NNTP-Posting-Host: 154.5.109.48
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:102334
X-Tomcat-NG: microsoft.public.dotnet.general

I want to check chose performance related parameters in my code.
Thanks!


Jul 19 '05 #2

P: n/a
BTW, there is a long recent thread on this with many suggestions in this
group under "profiling .net application"

"Ryan Byington" <ry*****@online.microsoft.com> wrote in message
news:k5**************@cpmsftngxa06.phx.gbl...
Performance counters may be what you are looking for. You can run
perfmon(jsut go to the start menu then run and type "perfmon" and hit
enter) to view all of the available performance counters on your machine.
Click the + icon in the toolbar to add other performance counters to the
view.

In the .Net Framework we have a class called PerformanceCounter in the
Diagnostics namespace. This type allows you to access all of the
performance counters that you can view in perfmon. If you wanted the %CPU
you would do something like the following:

PerformanceCounter percentCpu = new PerformanceCounter("Processor", "%
Processor Time", "_Total");

while(true) {
Console.WriteLine("% CPU:{0}", percentCpu.NextValue())
System.Threading.Thread.Sleep(1000);
}

See the following link on MSDN for more information:
http://msdn.microsoft.com/library/de...us/cpref/html/ frlrfsystemdiagnosticsperformancecounterclasstopic .asp

Ryan Byington [MS]
This posting is provided "AS IS" with no warranties, and confers no
rights.Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
--------------------
From: "davidw" <wy*****@hotmail.com>
Subject: How to find out how many instances are running and the current

CPU usage rate.
Date: Thu, 24 Jul 2003 12:17:37 -0700
Lines: 6
Organization: Affinisys Inc.
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <ul**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.general
NNTP-Posting-Host: 154.5.109.48
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:102334
X-Tomcat-NG: microsoft.public.dotnet.general

I want to check chose performance related parameters in my code.
Thanks!

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.