This is a mirror of official site: http://jasper-net.blogspot.com/

TraceNet : Trace the method level performance for dlls in Asp.net applications, without writing any performance tracing code!

| Sunday, October 10, 2010
I know, you will love it. Why? Because of the following reasons:

The built-in tracing engine in Asp.net gives you some tracing information about the methods and events in the CodeBehind of Pages and user controls. But, it doesn’t tell you the full story. Your applications are typically multi-layered and you have different layers performing different functionality. Each different layer is usually implemented in a class library which outputs an assembly (dll) to be referenced and used by the main application to carry out its work, and, Asp.net tracing cannot trace the methods written within these class libraries (dlls).

Typically, the business logic methods are being called from the methods and events written in the CodeBehind files, and, the data access/operation methods are being called from within the business logic methods. So, when you want your application to perform efficiently, you would want to make sure that it executes all methods in CodeBehind, business logic layer and data access layer as efficient as possible. To make sure this, you obviously need to know how much execution time is currently being taken by all these methods, so that you can identify which methods are performing inefficiently and after optimization you can identify whether performance is really improved and if yes, how much performance is gained.

Well, obvious story. Everyone knows that. Asp.net Tracing gives you the execution time each CodeBehind method is taking. Unfortunately, the Asp.net tracing does not tell you how much execution time is taken by the methods within the methods in those different layers. But, is it really hard to measure how much execution time these methods are taking? Not really. Let’s look at the following example:

public void AMethod()
{
       //Capture the starting time

       DateTime startTime = DateTime.Now;

       //do some operations

       //Capture the ending time

       DateTime endTime = DateTime.Now;

       //Find the time difference, this is the execution time of the method

       TimeSpan executionTime = (endTime - startTime).TotalMilliSeconds;
}

Basically, this method measures the execution time just by calculating the time difference between the start time and end time recorded before and after the code execution within the method. The logic is quite simple, and, its a matter of three lines of code only.

Read more: Codeproject

Posted via email from .NET Info

0 comments: