D
davidw
I want to check chose performance related parameters in my code.
Thanks!
Thanks!
Ryan Byington said: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/default.asp?url=/library/en-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 athttp://www.microsoft.com/info/cpyright.htm
--------------------
From: "davidw" <[email protected]>
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: <[email protected]>
Newsgroups: microsoft.public.dotnet.general
NNTP-Posting-Host: 154.5.109.48
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.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!