473,378 Members | 1,393 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,378 software developers and data experts.

Writing Windows performance counters

Hello group,

I'm trying to write code to test an application we're developing. This
application needs to store its own performance data in the registry, and
we'd like to be storing quite a large amount of performance data and
updating it fairly quickly. Not surprisingly, we keep coming up with more
and more performance data we'd like to be writing to the registry.

My job is to come up with a test harness to establish the following:
- create X new Windows performance counters and update each of them every
Y milliseconds with some (random) value

I then need to try this for various values of X and Y, and note how the
performance of the overall application/system drops off as we increase X
and Y. We'll then draw a line in the sand and say "X and Y must be less
than these values", and go forward from there.

Could someone point me towards some sample code that creates performance
counters and updates them? I suspect it's possible using perfmondata.dll
that comes with win32all, but can't begin to guess how to get started.

Thanks in advance

Dave M.
Jul 18 '05 #1
2 4712
If you've installed Mark's win32all packages, look in your win32/lib
directory for win32pdhutil and win32pdhquery, as well as
win32/scripts/killProcName.py .

HTH,
Mike

David Mitchell wrote:
....
Could someone point me towards some sample code that creates performance
counters and updates them? I suspect it's possible using perfmondata.dll
that comes with win32all, but can't begin to guess how to get started.

....
_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/

Jul 18 '05 #2
David Mitchell wrote:
Could someone point me towards some sample code that creates performance
counters and updates them? I suspect it's possible using perfmondata.dll
that comes with win32all, but can't begin to guess how to get started.


I thought there was sample code in win32all, but it looks like it never
got created - but 1/2 of it is there.

The win32\demos\service\install directory has a .h and a .ini file that
are used by Windows itself when installing the perfmon data.

Somewhere, your runtime code should implement code similar to:

counters = [] # Empty list to fill with counters.

# Counter of document opens.
# Magic numbers (2, 4, 6) must match header and ini file used
# at install - could lookup ini, but then I'd need it at runtime
counterSomething=perfmon.CounterDefinition(2)
counterSomething.DefaultScale = 1
counters.append(counterSomething)

counterSomethingElse=perfmon.CounterDefinition(4)
counterSomethingElse.DefaultScale = 1
counters.append(counterDocSave)

perfObjectType = perfmon.ObjectType(counters)

# end of sample

The magic numbers must match the .h and .ini (which is a requirement of
Windows, not us!) Once the above code has been run, 'counterSomething'
and 'counterSomethingElse' can have their 'Increment' method called, to
increment the counter.

Note that I don't try and hide the win32 gory details here, so you
really must read the MS documentation on this complicated mechanism.

Let me know if you would like any help. A very useful thing to do would
be to create a sub-class of the existing demo service, with the subclass
doing nothing other than providing the perfmon data. This was always my
intent. If you have trouble getting it going, providing the above as
sample code to demonstrate your problem would get a good response ;)

Mark.

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: sidd | last post by:
Hi All, i have some doubts on .net windows services.. please see if some one could help me understand this.. 1)is it possible to install a windows service which does not have a installer added...
0
by: rob_c | last post by:
Hi, I've been working with the EIF for a few days now. One of the default event sinks provided is the WMI. I've played around a bit and can send events to the WMI. My question here centers on...
0
by: Christopher Attard | last post by:
Hi, I need to create a dialog like the 'Add Counters' dialog box in perfmon. I'm using the System.Diagnostics namespace class in .NET and I've managed to do it. The problem arises when I'm...
9
by: SP | last post by:
Hi All, I wrote a windows service which is supposed to stop after specified amount of time. I am calling OnStop() after specified time. OnStop() methods executed but I dont see the service...
3
by: BC | last post by:
Hi all, I have a windows service (on client machine) that monitors a MSMQ queue (on server machine). When a new message is in the server queue, the client windows service will get the message...
7
by: James | last post by:
Hi Has anybody had any experience of ASP.Net performance counters not updating. In the performance monitor application when I try to add the groups ASP.NET and ASP.NET Applications the...
19
by: Tom Jastrzebski | last post by:
Hello, I was just testing VB.Net on Framework.Net 2.0 performance when I run into the this problem. This trivial code attached below executed hundreds, if not thousand times faster in VB 6.0...
0
by: supreeth.bhat | last post by:
I created a new Performance Counter Category and added three new counters. Used InstallUtil.exe to create them on remote production server. I can see the custom counter category and counters. ...
1
by: Robert Strickland | last post by:
I have a .Net web service (written for 1.1 Framework using C#) running on Windows 2003 with all latest patches. To help monitor the service, the code creates several performance counters. One...
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...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.