Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Performance / May 2006

Tip: Looking for answers? Try searching our database.

Need to set PerformanceCounter.RawValue to a double value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vecozo@online.nospam - 08 May 2006 19:25 GMT
Hi,

Is it possible to set the double (or perhaps *calculated*) values of a
Windows NT performance counter? We use the PerformanceCounter.RawValue
property to set counters, such as the total number of requests on a certain
application. However, PerformanceCounter.RawValue is of type long but we
require to set a double value  (e.g. to set an averages). An option would be
if we were able to set the denominator and nominator of the calculated value.

I hope you be of any assistance.

Regards,
Martijn Kaag

* Background:
We are working on a library that instruments our applications. The library
collects custom counters (“sources”) and every x minutes distributes these
collected values to various “sinks” such as a database, a user interface or
Windows NT performance counters using the System.Diagnostics namespace.
Because we have our own Counter objects that calculate the average, frequency
etc we do not use the default PerformanceMonitor.Increment and
PerformanceMonitor.IncrementBy methods.
Greg Young - 08 May 2006 19:46 GMT
Better might be to look at AverageXXX performance counters
...CountPerTimeInterval sounds particularly useful for you in this case.
http://www.informit.com/guides/content.asp?g=dotnet&seqNum=254 gives some
examples. The RawFraction type (also included in that article) is exactly
what you describe below.

Cheers,

Greg Young
MVP - C#

> Hi,
>
[quoted text clipped - 23 lines]
> etc we do not use the default PerformanceMonitor.Increment and
> PerformanceMonitor.IncrementBy methods.
vecozo@online.nospam - 08 May 2006 21:17 GMT
Thanks Greg!

The link cleared up a lot. It works!

Regards,
Martijn

PS For those who are looking for the same answer:
What I did not understand before was that you actually need two performance
counters, a XXXBase (denominator) and an AverageXXX (nominator):

// Add the counter.
               CounterCreationData rawFraction = new CounterCreationData();
               rawFraction.CounterType =
PerformanceCounterType.AverageCount64;
               rawFraction.CounterName = averageCounterName;
               CCDC.Add(rawFraction);

               // Add the base counter.
               CounterCreationData rawFractionBase = new
CounterCreationData();
               rawFractionBase.CounterType =
PerformanceCounterType.AverageBase;
               rawFractionBase.CounterName = averageCounterNameBase;
               CCDC.Add(rawFractionBase);

The averageCounterName now reads [rawFractionCounter].rawvalue /  
[rawFractionBase].rawvalue.

______________________________

> Better might be to look at AverageXXX performance counters
> ....CountPerTimeInterval sounds particularly useful for you in this case.
[quoted text clipped - 34 lines]
> > etc we do not use the default PerformanceMonitor.Increment and
> > PerformanceMonitor.IncrementBy methods.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.