Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time taken for page to load 2

Status
Not open for further replies.

biddingbong

IS-IT--Management
Sep 10, 2004
67
MU
Wat I want is the time take in seconds.milliseconds which the page took to load.

I've been thinking sonething like this:
<%
Get the time
%>
<html>
<head><title></title></head>
<Body>
talbes, images...etc...
</body>
<%
Get second time
Compare the 2 times
response.write the difference
%>
</html>

I dont know if the logic is good and also I dont know how to capture the time and display it in seconds.milliseconds
 
thats the logi i use. i know how to get it in seconds, u have to use datediff function:
<%
StartTime=Now
......
EndTime=Now
SecondsTaken=datediff("s",StartTime,EndTime)
response.write SecondsTaken
%>

Known is handfull, Unknown is worldfull
 
That will give you the server-side execution time, not necesarally the load time. M<ethod I use to get the loading time (I display both on one site) is to output my <html><head> tag at the very top (before other logic) and a chunk of javascript to get the time, as well as a function to write the current time - the inital time to a div. Later on when I output the body tag I put a call to that function in the onLoad so I get exact amount of time it took from when the browser first received data to when the onLoad event actually fired (page done completely loading). Found some interesting results now and again where the server-side execution time only takes 4 or 5 seconds but then the browser takes 30 seconds to render everything :p

-T

barcode_1.gif
 
Can you give some codes?
Javascript is not my cup of tea.
 
Sure, here is an example from one site.
The first section I output at the very top of thepage before I do any other work (note the response.Flush to push it to the client browser immediately):
Code:
<script language="javascript">
		var renderStart;
		renderStart = new Date;
		renderStart = renderStart.getTime();
	
		<%Response.Flush%>

		function showRender(){
			var renderEnd = new Date;
			renderEnd = renderEnd.getTime();
			document.getElementById("rendertime").innerHTML = "Browser Rendered in " + (renderEnd - renderStart)/1000 + " seconds."
		}
	</script>
All this does is define the renderStart time and the end function that subtracxts the start time from the current time. You'll notice that it expects for a target DIV in the body to have the id "rendertime". This is where it is writing the time.

Then all you need to do is to call the function in your onLoad:
Code:
	<body onLoad="showRender();">
That way it records the end time as the time the browser finishes rendering everything and throws the onLoad event.

-T

barcode_1.gif
 
Tarwn,
i used to use that code, but the problem is that sometimes the client systems will not execute it correctly. i used to follow ur method uptil 2 days back thats but this is what happened:

ASP - 15 secs
Javascript - 6 secs

The difference is HUGE...

Known is handfull, Unknown is worldfull
 
Yeah, my only guess is that the browser waited for more data to show up befire it started rendering, plus there is the communication time for the first set of packets, and the internal time it takes between ASP telling the buffer to flush andit actually getting flushed (can't remember if the buffer is threaded seperatey, if it is that could be part of the time issue).
]
Like I said earlier, the javascript method is strictly how long it takes the browser to render based on first packet arrival to body fully loaded. The ASP version is only measuring the time it takes to create all the HTML, not including rendering and communications time. Unfortunatly they overlap so neither is really an accurate loadtime from the client's point of view and you can't simply add them together to get an answer.

-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top