Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Creating performance counters

Creating performance counters

Scheduled Pinned Locked Moved C / C++ / MFC
comquestionc++sysadmin
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mike Dimmick
    wrote on last edited by
    #1

    I realise this is a very advanced question! I have a server application which I'm trying to add performance counters to, to allow the server's performance to be monitored using standard tools, such as the System Monitor ActiveX control (most users will know this as part of the Performance management console in Administrative Tools). There's a reasonable amount of documentation on actually creating your performance counters, and I'm using a chunk of code that came with my copy of 'Programming Server-Side Applications for Windows' by Jeff Richter and Jason Clark. I've already got a number of simple counters (those using PERF_COUNTER_COUNTER and PERF_COUNTER_RAWCOUNT) running. My problem is that I've got a piece of data I want to expose and no idea how to define this counter. I'd like to be able to show the average percentage utilisation of a set of worker objects, defined as the average amount of time they were used in the sample period. The value shown should be ((current sample - last sample) / (number of objects)) / (current sample time - last sample time). Doing this allows me to simply add the duration of an operation to the counter. It doesn't look like this is possible, though, certainly with the standard counter types. The actual server is written in VB6 so I'd like to avoid 64-bit counters and timers if at all possible! I'm writing the performance counter values using a C++ DLL which the VB6 code calls into. I can divide the time elapsed by the number of objects myself, but this obviously loses accuracy, since it's an integer division. Any ideas greatly appreciated. Stability. What an interesting concept. -- Chris Maunder

    J M 2 Replies Last reply
    0
    • M Mike Dimmick

      I realise this is a very advanced question! I have a server application which I'm trying to add performance counters to, to allow the server's performance to be monitored using standard tools, such as the System Monitor ActiveX control (most users will know this as part of the Performance management console in Administrative Tools). There's a reasonable amount of documentation on actually creating your performance counters, and I'm using a chunk of code that came with my copy of 'Programming Server-Side Applications for Windows' by Jeff Richter and Jason Clark. I've already got a number of simple counters (those using PERF_COUNTER_COUNTER and PERF_COUNTER_RAWCOUNT) running. My problem is that I've got a piece of data I want to expose and no idea how to define this counter. I'd like to be able to show the average percentage utilisation of a set of worker objects, defined as the average amount of time they were used in the sample period. The value shown should be ((current sample - last sample) / (number of objects)) / (current sample time - last sample time). Doing this allows me to simply add the duration of an operation to the counter. It doesn't look like this is possible, though, certainly with the standard counter types. The actual server is written in VB6 so I'd like to avoid 64-bit counters and timers if at all possible! I'm writing the performance counter values using a C++ DLL which the VB6 code calls into. I can divide the time elapsed by the number of objects myself, but this obviously loses accuracy, since it's an integer division. Any ideas greatly appreciated. Stability. What an interesting concept. -- Chris Maunder

      J Offline
      J Offline
      Jonathan Darka
      wrote on last edited by
      #2

      Have you tried breaking the calculation up into seperate lines of code and using casts to correct the data types between each operation.


      Darka [Xanya]

      1 Reply Last reply
      0
      • M Mike Dimmick

        I realise this is a very advanced question! I have a server application which I'm trying to add performance counters to, to allow the server's performance to be monitored using standard tools, such as the System Monitor ActiveX control (most users will know this as part of the Performance management console in Administrative Tools). There's a reasonable amount of documentation on actually creating your performance counters, and I'm using a chunk of code that came with my copy of 'Programming Server-Side Applications for Windows' by Jeff Richter and Jason Clark. I've already got a number of simple counters (those using PERF_COUNTER_COUNTER and PERF_COUNTER_RAWCOUNT) running. My problem is that I've got a piece of data I want to expose and no idea how to define this counter. I'd like to be able to show the average percentage utilisation of a set of worker objects, defined as the average amount of time they were used in the sample period. The value shown should be ((current sample - last sample) / (number of objects)) / (current sample time - last sample time). Doing this allows me to simply add the duration of an operation to the counter. It doesn't look like this is possible, though, certainly with the standard counter types. The actual server is written in VB6 so I'd like to avoid 64-bit counters and timers if at all possible! I'm writing the performance counter values using a C++ DLL which the VB6 code calls into. I can divide the time elapsed by the number of objects myself, but this obviously loses accuracy, since it's an integer division. Any ideas greatly appreciated. Stability. What an interesting concept. -- Chris Maunder

        M Offline
        M Offline
        Mike Dimmick
        wrote on last edited by
        #3

        Well, in case anyone else finds this: My solution is to use a counter of type PERF_100NSEC_TIMER, which is the type used by, for example, the Processor\% Idle Time counter. I'm still supplying the time in milliseconds but have extended my DLL to multiply up the value I pass in by 10000, to convert from 1ms to 100ns intervals. I'm dividing the value I pass by the number of objects, which leads to a degree of inaccuracy for objects used very infrequently but with a long execution time (showing 300% at one point using a 1s sample period) but since I'm more interested in the long-term average, this is acceptable. Stability. What an interesting concept. -- Chris Maunder

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups