Advertisement Jump to content
Sign in to follow this  

[.net] Using EXISTING performance counters???

This topic is 5202 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have looked all over for somewhere that tells me how to use windows existing performance counters in .NET but I can only find tutorials of how to add a custom performance counter whitch is not what I whant. I whant to be able to create and read the existing performance counters values. Does anyone know how to do this?

Share this post

Link to post
Share on other sites
I'll show you a snippet of my code. It was a web for showing a server's perfomance.

I had to remove all the irrelevant pices of code, but I'll hope you still get the point.
The first function shows all the performance categories, the second show the counters (name, value etc.) within a category.

Please let me know if I'm not clear enough.

Imports System.Diagnostics

Private Sub ShowPerfCat()

Dim loPerfCat() As PerformanceCounterCategory
Dim lsTextCat() As String

loPerfCat = PerformanceCounterCategory.GetCategories()

' sort performance categories
ReDim lsTextCat(loPerfCat.Length - 1)
For i As Int32 = 0 To loPerfCat.Length - 1
lsTextCat(i) = loPerfCat(i).CategoryName
Next i

' here we have an perfomance counter category
For i As Int32 = 0 To loPerfCat.Length - 1
Next i

End Sub

Private Sub ShowPerfCtr(ByVal CatName As String)

Dim loPerfCat As New PerformanceCounterCategory(CatName)
Dim loPerfCtr() As PerformanceCounter
Dim lsPerfInt() As String = loPerfCat.GetInstanceNames

For j As Int32 = 0 To lsPerfInt.Length - 1
loPerfCtr = loPerfCat.GetCounters(lsPerfInt(j))

For i As Int32 = 0 To loPerfCtr.Length - 1

' perfomance counter's name

' perfomance counter's value

' perfomance counter's type

' perfomance counter's description
Next i
Next j
End Sub

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!