Link to home
Start Free TrialLog in
Avatar of rwniceing
rwniceing

asked on

extract and substract between start and end-time for " for loop" in asp

Dear Exerts,

I try to extract the total execution time of the for loop in the following asp code
and since vbscript is not doing well  with miilli-second extraction, so I use javascript code
for extracting time in ms from start and ending of for loop.

Now the code is working, it show the Start and End time. But how to
do substraction  on start-time - end time ?

I tried  put  the end-time javascript right after <% %> similar code to the start time  javascript code. But it showed the wrong result that is why I put into head tag for end time javascript code.

Any better approach for doing that ?

Please advise

Rwniceing


<!DOCTYPE html>
<html>
<script language=javascript runat=server> 
var myvar = Date.UTC(a.getFullYear(),a.getMonth(),a.getDay(),a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds());
	response.write("Start time in ms: " + myvar );
    </script>
<%
Dim i,a,b,c
for i = 1 to 2e6
a=1234+5678+i
b=1234*5678+i
c=1234/2+i
next
response.write("<br/>(i,a,b,c)=" & i & "=" &  a & "=" & b & "=" &c & "<br/>")
%>
<body>
</body>
<head runat="server">
    <title>Demo Page for Test</title>
    <script language="javascript" type="text/javascript" >
 var a = new Date();
var myvar = Date.UTC(a.getFullYear(),a.getMonth(),a.getDay(),a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds());
	document.write("End&nbsp;&nbsp;time in ms: ",myvar);
   </script>
</head>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Robert Schutt
Robert Schutt
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rwniceing
rwniceing

ASKER

<%

Option Explicit

Response.Buffer = False ' not needed but lets you see the output as it is produced instead of all at once

%>

Open in new window


That is why on my topic post code, it will response.write the output after the for loop completion
and the start and end time is also correct but just echo out at the same time that is strange I feel.
Probably it is caused by the setting on response.buffer.
Done and thanks for your reply