Jeevan Bhatt
Jeevan Bhatt

Reputation: 6101

How to check performance/(actual time) of a particular action in asp.net?

There are a lot of buttons in my web form (asp.net), want to know following things:

  1. I want to know actual time of page load.
  2. I user perform any action then how much time it take to complete.
  3. If i click a button then which functions get called during this action.

I want all in at the time of development, means i don't want to deploy project some where and then check it from fiddler kind of tool. There must be some thing in VS2008 asp.net from where we can get how much time a particular action takes.

Upvotes: 1

Views: 179

Answers (2)

jhsowter
jhsowter

Reputation: 619

Turn on tracing

You can turn on tracing on a single page using the Trace attribute in the Page directive.

<%@ Page Trace="true" %>

You can also turn on tracing for all pages in an asp.net application using the web.config setting.

<configuration>
  <system.web>
    <trace enabled="true" pageOutput="false" requestLimit="40" localOnly="false"/>
  </system.web>
</configuration>

Add custom output to the trace output.

public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Trace.Write("custom start");
            System.Threading.Thread.Sleep(2000);
            Trace.Write("custom end");
        }
    }

The above code shows up like this

enter image description here

Upvotes: 1

Uwe Keim
Uwe Keim

Reputation: 40726

For me, what work best in the past is to use a performance profiler.

I've tried various tools and ended with buying Red Gate's ANTS Performance Profiler. They have a 14 days free trial, so you can actually see whether you have a benefit from using the tool.

I experiences that I was wrong most of the time when assuming the cause of a performance bottleneck in contrast to actually measuring it.

Upvotes: 0

Related Questions