How the page gets the load time of the ASP page
<!---How can I time the execution speed's my ASP pages to the millisecond? --->
Doing this are easy with a simple server-side JavaScript function:
<script Language=jscript runat=server>
function GetTime ()
{
var d = new Date ();
return D.gettime ();
}
</script>
The GetTime () method of the Date object in JScript returns the number of millisecond since 1st, 1970. Therefore all your have to does it take a reading immediately before and after the process for your are to time. The following is a example, given the above code it in gettime.asp:
Dim StartTime, Endtime
StartTime = GetTime ()
' Do some stuff here
Endtime = GetTime ()
Response.Write "The process took:" & _
Cstr (endtime-starttimes) & "Ms to execute"
If you want to the your process time in a better format, use the Formatmilliseconds function (created for the above Script by www.learnasp.com):
function Formatmilliseconds (intmilliseconds)
{
var elapsedsecs = 0
Ar elapsedmins = 0
Elapsedsecs=math.floor (intmilliseconds/1000);
intmilliseconds=intmilliseconds%1000;
Elapsedmins=math.floor (ELAPSEDSECS/60)
elapsedsecs=elapsedsecs%60;
Elapsedpretty=elapsedmins + "Minute";
if (elapsedmins!=1)
Elapsedpretty=elapsedpretty+ "S";
Elapsedpretty = elapsedpretty+ "" + elapsedsecs+ "second";
if (elapsedsecs!=1)
Elapsedpretty=elapsedpretty+ "S";
Elapsedpretty = elapsedpretty+ "" +
intmilliseconds+ "Millisecond";
if (intmilliseconds!=1)
Elapsedpretty=elapsedpretty+ "S";
return elapsedpretty;
}