Thomas,

To use performance counters is easy, you just need a couple of objects from
the framework. Here's some sample code that creates a performance counter
group and two counters, then increments and decrements the counters.
Here's a VB.NET example:

-------------------
        'Create a preformance counter group
        If Not PerformanceCounterCategory.Exists("MyPerfCounters") Then
            'create a couple of counters
            Dim ccds As New CounterCreationDataCollection()
            ccds.Add(New CounterCreationData("MyFirstPerfCounter", "",
PerformanceCounterType.RateOfCountsPerSecond32))
            ccds.Add(New CounterCreationData("MySecondPerfCounter", "",
PerformanceCounterType.NumberOfItems32))
            PerformanceCounterCategory.Create("MyPerfCounters", "Example
Perf counter group", ccds)
        End If

        'to use the counter just call Increment or Decrement....
        Dim FirstPerfCounter As New PerformanceCounter("MyPerfCounters",
"MyFirstPerfCounter", "", False)
        Dim SecondPerfCounter As New PerformanceCounter("MyPerfCounters",
"MySecondPerfCounter", "", False)

        FirstPerfCounter.Increment()
        SecondPerfCounter.Decrement()
--------------------

What you're looking for in your second question is called "conditional
compliation." It uses the #IF syntax in VB.NET.
Here's an example:
-----------------------
#If Debug Then
        MessageBox.Show("We're in a debug compile!")
#Else
        messagebox.Show("We're in a release compile!")
#End If
-----------------------

Good luck to you....
-Andy

Andy Johns, MCSD
Senior Consultant-Architect
Magenic Technologies


-----Original Message-----
From: Thomas V. Nielsen [mailto:[EMAIL PROTECTED]] 
Sent: Monday, September 09, 2002 12:18 AM
To: dotnet
Subject: Need hints to mesure performance


Anybody got any ideas/hints, how to log/mesure performance in a method,
perhaps using the .NET FrameWork use of Performance Counters.

In SQL you can specify that a stored procedure should use a given
performance counter, how would one do the same in .NET?

And how do you specifi in a method that this logic is when it is compiled
for debug, and this is for release?

<Thomas/>



---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to %%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search Subscription
Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/



---
You are currently subscribed to dotnet as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/


Reply via email to