欢迎光临
我们一直在努力

如何获得asp页面的载入时间(转)

建站超值云服务器,限时71元/月

如何获得asp页面的载入时间

<!— how can i time the execution speed of my asp pages to the millisecond? —>

doing this is 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 jan 1st, 1970. therefore all you have to do it take a reading immediately before and after the process you are wanting to time. the following is an example, given that 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 see your process time in a better format, use the formatmilliseconds function (created for the above timing 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;
}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 如何获得asp页面的载入时间(转)
分享到: 更多 (0)