ANTS Performance Profiler 7

Isolating single ASP .NET pages in ANTS Profiler results

ANTS Profiler does not offer any features specific to ASP .NET web applications, however, it is possible to mark the timeline of ANTS Profiler at the point that an ASP .NET page loads and unloads. This way the results can be filtered to more or less only the code that had been run by a particular page.

Creating an event on the ANTS Profiler timeline requires referencing one of ANTS Profiler's DLLs and adding a line of code to the page's "Page_Load" and "Page_Unload" event handlers. ASP .NET automatically looks for methods called "Page_Load" and "Page_Unload" on an ASP .NET code file by default, or when the "AutoEventWireup" page directive is used. One or both of these methods may exist in your code. If they do not, they can be created manually using the standard parameters for an event handler as shown in the examples below.

First, copy the file "RedGate.Profiler.UserEvents.dll" from the "%programfiles%\red gate\ants profiler 4" folder to the "Bin" folder of your web application. If the Bin folder does not exist, it can be created manually using Windows Explorer. Next, add the code necessary to trigger a user event in the ANTS Profiler timeline into your ASP .NET page code file:

public partial class _Default : System.Web.UI.Page
{
...
protected void Page_Load(object sender, System.EventArgs e)
    {
            // Will run when the page loads
            RedGate.Profiler.UserEvents.ProfilerEvent.SignalEvent("Default.aspx Loaded.");
    }

 protected void Page_Unload(object sender, System.EventArgs e)
    {
            // Will un when the page unloads
            RedGate.Profiler.UserEvents.ProfilerEvent.SignalEvent("Default.aspx Unloaded.");
    }
...
}

When this page is saved and the web application profiled, the following events will appear at two different points in the timeline:

User event
Message: Default.aspx Loaded.
...
User event
Message: Default.aspx Unloaded.

Clicking in the timeline directly under the first event and dragging until the second event is reached will narrow down the code to only code run in the page "Default.aspx", provided there were no concurrent accesses to this page or background threads started by this page.


Didn't find what you were looking for?