Writing Windows performance counters

Discussion in 'Python' started by David Mitchell, Feb 9, 2004.

  1. 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.
     
    David Mitchell, Feb 9, 2004
    #1
    1. Advertising

  2. 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/
     
    Mike C. Fletcher, Feb 9, 2004
    #2
    1. Advertising

  3. David Mitchell

    Mark Hammond Guest

    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.
     
    Mark Hammond, Feb 9, 2004
    #3
  4. David Mitchell

    Saravanan D Guest

    Examples which are given the OReilly site (Python Win32 Programming) does
    not work properly. Could you please help me on that.

    Saravanan D
    "Mark Hammond" <> wrote in message
    news:c074fa$2shp$...
    > 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.
    >
     
    Saravanan D, Feb 18, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Erik Cruz

    .NET Clr Data performance counters

    Erik Cruz, Oct 27, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    2,274
    Erik Cruz
    Oct 27, 2003
  2. Michael Carr
    Replies:
    0
    Views:
    585
    Michael Carr
    Jan 9, 2004
  3. Michael Carr
    Replies:
    4
    Views:
    2,559
    John Soulis [MSFT]
    Jan 12, 2004
  4. Dmitry Duginov

    Performance counters

    Dmitry Duginov, Dec 1, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    753
    Steven Cheng[MSFT]
    Dec 7, 2004
  5. Brian Newtz
    Replies:
    0
    Views:
    573
    Brian Newtz
    Dec 13, 2004
Loading...

Share This Page