473,323 Members | 1,547 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,323 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 6270
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.