tags:

views:

547

answers:

5

Say, I want to calculate the time taken to load a ASP.NET page. When a user types the URL and presses enter, the following events take place:

  1. Request is sent to the server
  2. Server processes the request, executes any on load server side logic, makes DB calls
  3. Browser receives the response, downloads HTML and JS files
  4. Browser runs client side logic (Javascript functions on load)
  5. Browser renders the page

If I would like to measure the time taken for each of these operations, my understanding is that I can use the following tools:

  1. For (1), use Fiddler to calculate time over the Network
  2. For (2), switch on trace to calculate time for server side processing
  3. For (3), use Fiddler to calculate the time taken for download
  4. For (4), use firebug for time taken by JS functions

Summing up 1 to 4 gives the total time taken.

Is my thinking correct? Is there one tool that does all this? Is there an easier way

+4  A: 

Firebug will actually give you 1 and 3 as well in the "Net" tab, and provides nice little split-up graphical bars that show you the components of the response time (DNS lookup, querying the server, waiting for first byte, download time).

There isn't really one tool that could possibly do both the client and server measurements, since the server code is running on the server, and the client code is running on the client. You could approximate simply by subtracting away all the other times from the total, but the most accurate server result will indeed be from the server itself.

womp
Although the server side code is running on the server, since the client is still waiting while this is happening, why cant we capture this on the client?
The client does capture it, as a component of the response time. However, that also takes into account every network hop the traffic has to go through to get to you, and the read time (TTFB, TTLB), so it won't be as accurate as the server's calculation, which can start a timer as soon as the request is receiver, and stop it right before it's writing the output.
womp
So, is it safe to say that Response time covers steps 1, 2, 3?
Sort of. Response time covers total response time. 1% of that could be network lag with the other 99% server processing time, or the other way around. Your #2 is most accurately given by a trace on the server. If you're actually only interested in the total response time, then yes it covers it. If you're interested in your code execution time, then it doesn't accurately cover it.
womp
Excellent. So, I guess I can grab the response time, add the JS execution time and I should be pretty much covered. It appears that the IE8 profiler does not have the Net tab. Is there a way to get the response time when using IE?
Also, I guess I am doing something wrong. The net tab shows a total of 7 seconds. But it seems to be loading in about 3 seconds (measured by the computer clock)
A: 

The Visual Round Trip Analyzer is a good program that uses NetMon to calculate your steps #1, 2, & 3. It can tell you how much time your network takes and the processing time on the server.

Step #4 is the hard one since different browsers will start displaying the content as different times.

David
+1  A: 

There is a plugin for FireFox that supports this need:

Google Page Speed - This tool will let you record web activity live and then view each portion of requests. How long they take and what components run in parallel.

Additionally, if you are looking to optimize a page, YSlow can provide other advice, though it doesn't give you the specific data you're asking for.

Michael La Voie
Google Page speed also requires FireBug
Neil
Does YSlow cover steps 1, 2, 3, 4?
My bad YSlow is just a helpful optimization tool, it doesn't show you the true time for round trip requests. Google Page speed does show this and it is pretty helpful for figuring out where your real bottlenecks are.
Michael La Voie
A: 

Why don't you just use the Browser Control in .NET and create your own app to test the time taken the from initial request to final response?

ftank99
A: 

For point number 2,

in global.asax

Private sw As Stopwatch = Nothing
Private Sub Global_asax_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.BeginRequest
    sw = Stopwatch.StartNew
End Sub

Private Sub Global_asax_EndRequest(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.EndRequest
    If sw IsNot Nothing Then
        sw.Stop()
        Response.Write("<b>took " & sw.Elapsed.TotalSeconds.ToString("0.#######") & " seconds to generate this page</b>")
    End If
End Sub
Fredou
This assums a single user... what about if you have 80 requests per second...
MrHinsh
@mrHinsh, that is what he asked
Fredou