免费下载: Ghost全自动系统备份光盘正式版 V4.5 | 硬盘版 V2.0 | 排行榜 TOP50 玩玩小游戏:连连看游戏网 http://www.llkyx.com
首页 >> Asp编程 >> Asp经验技巧 >> asp程序运行速度测试

asp程序运行速度测试

时间:2008-2-11 网友评论条 【

asp程序运行速度试验实验:

1。作相同的分支条件判断:IF  比  SELECT慢。

用以下程序测试:

<%
dim tttt1,ttt2
session("ii")=0
for sn=0 to 5
ttt1=now()
for i=0 to 300000
   if session("ii")=0 then
      session("ii")=1
   else
     if session("ii")=1 then
      session("ii")=2
     else
       if session("ii")=2 then
          session("ii")=3
        else
           session("ii")=0
         end if
     end if
   end if
next
ttt2=now()
tou=ttt2-ttt1
Response.Write sn&"、"&tou*24*60*60&"<br>"
next

for sn=0 to 5
ttt1=now()
for i=0 to 300000
   select case session("ii")
      case 0
         session("ii")=1
      case 1
         session("ii")=2
       case 2
         session("ii")=3
       case 3
         session("ii")=0
   end select
next
ttt2=now()
tou=ttt2-ttt1
Response.Write sn&"、"&tou*24*60*60&"<br>"
next

%>

2, 如果把上例中的SESSION对象改为用普通的变量存。速度会快差不多8倍

3,进行字符串连接时往中间加入相同多的字符串,基数越大,越慢。

通过下面的程序测试:

<%
dim tttt1,ttt2
session("ii")=0
for sn=0 to 5
ttt1=now()
'  txt=""
   for i=0 to 10000
       txt="a"&txt
   next
ttt2=now()
tou=ttt2-ttt1
Response.Write sn&"、"&tou*24*60*60&"<br>"
next
%>

进行同样长字节的字符连接时,汉字比英文快4倍,通过下面的程序测试

<%

dim tttt1,ttt2
for sn=0 to 5
ttt1=now()
  txt=""
   for i=0 to 20000
          txt="人"&txt
   next
ttt2=now()
tou=ttt2-ttt1
Response.Write sn&"、"&tou*24*60*60&"<br>"
next

txt=""
for sn=0 to 5
ttt1=now()
  txt=""
   for i=0 to 20000
          txt="aa"&txt
   next
ttt2=now()
tou=ttt2-ttt1
Response.Write sn&"、"&tou*24*60*60&"<br>"
next

%>

站长工具
英文域名注册及Whois查询:
相关文章
loading 请稍等,评论加载中...

Aspxhome.com. 中国Asp之家. 版权所有

闽ICP备06017341号