Home>

In the asp program, it is very simple to calculate how much time a page takes from the beginning to the end of execution! we know,asp is an interpreted language,In other words, the execution process is from the beginning of the page to the end of the page.We only need to calculate a time difference to get the page execution time.

Let ’s see how it works.In three steps!

Step 1:Define a variable for the start time in the header of the page.And get the current time

<%
dim startime
startime=timer ()
%>

Step 2:Define an end time variable at the end of the page.And get the current time

<%
dim endtime
endtime=timer ()
%>

Step 3:Calculate the two time differences,And output the pageThe execution time of the current page:<%= formatnumber ((endtime-startime) * 1000, 3)%>milliseconds

Is not it simple?Here is the complete example code for the execution time of the asp page:

<%@language="vbscript" codepage="936"%>
<%
dim startime
startime=timer ()
%>
<! Doctype html public "-//w3c //dtd xhtml 1.0 transitional //en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=gb2312" />
<title>Get time for asp page execution</title>
</head>
<body>
  <div align="center">
    <img src="xc_images/logo.jpg" />
  </div>
  <div align="center">
    <%
    for i=1 to 10000
      "Cycle costs some flowers!
    next
    %>
  </div>
  <br>
</body>
</html>
<%
dim endtime
endtime=timer ()
%>
<div align="center">the current execution time of the page:<%= formatnumber ((endtime-startime) * 1000, 3)%>milliseconds //div
asp
  • Previous JS implements common TAB, pop-up layer effects (TAB tags, zebra crossing, masking layers, etc)
  • Next The most complete and practical regular expressions