views:

49

answers:

3

Hello, commonly on say PHP or other web frameworks getting the total response time is easy, just start the timer at the top of the file and stop it at the end.

In ASP.Net there is the whole Page Lifecycle bit though so I'm not sure how to do this. I would like for this response time recording to take place in a master page and the response time show up in the footer of pages. What would be the best way of doing this? Is there something built in to ASP.Net for it? Is it even possible to include the OnRender time?

+3  A: 

You can do it on the Global.asax, take a look at this article

void Application_BeginRequest(object sender, EventArgs e)
{
HttpContext.Current.Items["renderStartTime"] = DateTime.Now;
}

void Application_EndRequest(object sender, EventArgs e)
{
DateTime start = (DateTime) HttpContext.Current.Items["renderStartTime"];
TimeSpan renderTime = DateTime.Now - start;
HttpContext.Current.Response.Write("<!-- Render Time: " + renderTime + " -->");
}
alejandrobog
+2  A: 

You can either use

  • Application begin_request and end_request in global.asax
  • Use Firebug at client side to check the time it takes to load the page
  • Use Tracing features

Some information available at:

http://stackoverflow.com/questions/1395587/measure-asp-net-page-load-time

Vishal Seth
+1 for Page Trace
slugster
A: 

If you're running Visual Studio Team System (perhaps other versions too now) you can also use the Visual Studio Profiler (http://msdn.microsoft.com/en-us/magazine/cc337887.aspx) to profile what is taking the most time.

Graphain