Plunging into .NET Development

Weblog Pieter Gheysens
Microsoft .NET Development - C# - Enterprise Library - Visual Studio 2005 Team System - Compuware DevPartner - ...

Saturday, November 4

Performance Analysis - what to profile?

What to do if you have performance problems in your application and you are not really sure what's causing all this trouble. Well, start using a profiling tool (like Compuware DevPartner) to pinpoint your performance issues on the exact line(s) of code.

For the applications I profiled so far, I was always interested in the exact duration of external calls (towards a database, towards another application, ...) from the profiled applications. It turns out that the default setting of DevPartner Studio 8.1 does not take into account the duration of an external call.

In the screenshot above (generated results with DevParnter Studio 8.1) you can see that the sleepFor3seconds method is executed 10 times (Count column), but it takes 0 seconds (Time column). That's not the information I'm looking for - the sleepFor3seconds method takes actually 30 seconds in total! Ok, the Sleep method is not the most appropriate example here, but imagine that it's replaced by a call to a database ... The default behavior of DevPartner 8.1 is that it excludes time spent in threads of other running applications. Luckily it's easy (but hard to find!) to include this external time as well. Go to your project in Visual Studio and hit F4 to display the Project Properties. There you can toggle the Exclude Others setting and that will give the desired results (see screenshot below).

So, be sure what to profile! Sometimes it can be interesting to profile only your own .NET code, but in applications that are dependent of other applications it might be very appropriate to measure also the duration of the external calls.


Post a Comment

Links to this post:

Create a Link

<< Home