VBscript(ASP)计算程序运行时间,精度到毫秒让服务器执行50万次加法(整数运算)和20万次开方(浮点运算),记录其所使用的时间。 <br/>
VBscript(ASP)计算程序运行时间,精度到毫秒        
<%
VBscript(ASP)计算程序运行时间,精度到毫秒    
dim i,t1,t2,tempvalue,runtime1,runtime2
VBscript(ASP)计算程序运行时间,精度到毫秒    
'开始计算50万次加法所需时间
VBscript(ASP)计算程序运行时间,精度到毫秒
    t1=timer()
VBscript(ASP)计算程序运行时间,精度到毫秒    
for i=1 to 500000
VBscript(ASP)计算程序运行时间,精度到毫秒        tempvalue
= 1 + 1
VBscript(ASP)计算程序运行时间,精度到毫秒    
next
VBscript(ASP)计算程序运行时间,精度到毫秒    t2
=timer()
VBscript(ASP)计算程序运行时间,精度到毫秒    runtime1
=formatnumber((t2-t1)*1000,2)
VBscript(ASP)计算程序运行时间,精度到毫秒    
VBscript(ASP)计算程序运行时间,精度到毫秒    
'开始计算20万次开方所需时间
VBscript(ASP)计算程序运行时间,精度到毫秒
    t1=timer()
VBscript(ASP)计算程序运行时间,精度到毫秒    
for i=1 to 200000
VBscript(ASP)计算程序运行时间,精度到毫秒        tempvalue
= 2^0.5
VBscript(ASP)计算程序运行时间,精度到毫秒    
next
VBscript(ASP)计算程序运行时间,精度到毫秒    t2
=timer()
VBscript(ASP)计算程序运行时间,精度到毫秒    runtime2
=formatnumber((t2-t1)*1000,2)
VBscript(ASP)计算程序运行时间,精度到毫秒%
>
VBscript(ASP)计算程序运行时间,精度到毫秒
&nbsp;<font color=red><%=runtime1%> 毫秒</font>
VBscript(ASP)计算程序运行时间,精度到毫秒
&nbsp;<font color=red><%=runtime2%> 毫秒</font>
VBscript(ASP)计算程序运行时间,精度到毫秒

在作者自己电脑上的运行结果是

让服务器执行50万次加法(整数运算)和20万次开方(浮点运算),记录其所使用的时间。
 203.13 毫秒  156.25 毫秒

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-30
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-29
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
相关资源
相似解决方案