473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

I want to check chose performance related parameters in my code.
Thanks!
Jul 19 '05 #1
2 6273
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Martin V. | last post by:
Hello, Is the multiple instances capability of SQL2K mature enough for a Production system? We're looking at upgrading our hardware but the proposed solution calls for consolidating two...
1
by: enahar | last post by:
Hello, i want to find out how many instances of a form (say childForm1) is running using FindWindowEx but value return is always zero by this method. What wrong I am doing it..Can anybody...
14
by: spencer | last post by:
My client is going through a large project to replace existing data warehouse physical infastructure which is running DB2 8.1.6. In the past we had a much more distributed environment where we had...
2
by: Baybars | last post by:
New to access, but to deja.com. Looked through many posts, but can not find a good post for my problem (I believe there is, but my access level didn't allow me to understand). I have a table for...
8
by: Joe | last post by:
I need an Access application that can search dealers from my dealer list, in a 30 miles distance from the user. You may see many applications like this on the web if you search under "find a...
2
by: davidw | last post by:
I want to check chose performance related parameters in my code. Thanks!
8
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm trying to get a list of SQL Server Instances thru a VB.NET application. I have tried GetDataSource and SMO. I have also tried using ListSQLSvr.exe from...
3
by: dittytwo | last post by:
Hi all I have been looking around the web and can't seem to find a solution the solution that i have found and manipulated seems to bring back the whole list of currently running process's...
2
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.