1ASP程序运行速度测试程序运行速度试验结果:
  2ASP程序运行速度测试1。作相同的分支条件判断:IF  比  SELECT慢。
  3ASP程序运行速度测试用以下程序测试:
  4ASP程序运行速度测试<%
  5ASP程序运行速度测试dim tttt1,ttt2
  6ASP程序运行速度测试session("ii")=0
  7ASP程序运行速度测试for sn=0 to 5
  8ASP程序运行速度测试ttt1=now()
  9ASP程序运行速度测试for i=0 to 300000
 10ASP程序运行速度测试   if session("ii")=0 then
 11ASP程序运行速度测试      session("ii")=1
 12ASP程序运行速度测试   else
 13ASP程序运行速度测试     if session("ii")=1 then
 14ASP程序运行速度测试      session("ii")=2
 15ASP程序运行速度测试     else
 16ASP程序运行速度测试       if session("ii")=2 then
 17ASP程序运行速度测试          session("ii")=3
 18ASP程序运行速度测试        else
 19ASP程序运行速度测试           session("ii")=0
 20ASP程序运行速度测试         end if
 21ASP程序运行速度测试     end if
 22ASP程序运行速度测试   end if
 23ASP程序运行速度测试next
 24ASP程序运行速度测试ttt2=now()
 25ASP程序运行速度测试tou=ttt2-ttt1
 26ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&"<br>"
 27ASP程序运行速度测试next
 28ASP程序运行速度测试
 29ASP程序运行速度测试for sn=0 to 5
 30ASP程序运行速度测试ttt1=now()
 31ASP程序运行速度测试for i=0 to 300000
 32ASP程序运行速度测试   select case session("ii")
 33ASP程序运行速度测试      case 0
 34ASP程序运行速度测试         session("ii")=1
 35ASP程序运行速度测试      case 1
 36ASP程序运行速度测试         session("ii")=2
 37ASP程序运行速度测试       case 2
 38ASP程序运行速度测试         session("ii")=3
 39ASP程序运行速度测试       case 3
 40ASP程序运行速度测试         session("ii")=0
 41ASP程序运行速度测试   end select
 42ASP程序运行速度测试next
 43ASP程序运行速度测试ttt2=now()
 44ASP程序运行速度测试tou=ttt2-ttt1
 45ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&"<br>"
 46ASP程序运行速度测试next
 47ASP程序运行速度测试
 48ASP程序运行速度测试%>
 49ASP程序运行速度测试2, 如果把上例中的SESSION对象改为用普通的变量存。速度会快差不多8倍
 50ASP程序运行速度测试3,进行字符串连接时往中间加入相同多的字符串,基数越大,越慢。
 51ASP程序运行速度测试通过下面的程序测试:
 52ASP程序运行速度测试<%
 53ASP程序运行速度测试dim tttt1,ttt2
 54ASP程序运行速度测试session("ii")=0
 55ASP程序运行速度测试for sn=0 to 5
 56ASP程序运行速度测试ttt1=now()
 57ASP程序运行速度测试'  txt=""
 58ASP程序运行速度测试   for i=0 to 10000
 59ASP程序运行速度测试       txt="a"&txt
 60ASP程序运行速度测试   next
 61ASP程序运行速度测试ttt2=now()
 62ASP程序运行速度测试tou=ttt2-ttt1
 63ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&"<br>"
 64ASP程序运行速度测试next
 65ASP程序运行速度测试%>
 66ASP程序运行速度测试进行同样长字节的字符连接时,汉字比英文快4倍,通过下面的程序测试
 67ASP程序运行速度测试<%
 68ASP程序运行速度测试
 69ASP程序运行速度测试dim tttt1,ttt2
 70ASP程序运行速度测试for sn=0 to 5
 71ASP程序运行速度测试ttt1=now()
 72ASP程序运行速度测试  txt=""
 73ASP程序运行速度测试   for i=0 to 20000
 74ASP程序运行速度测试          txt=""&txt
 75ASP程序运行速度测试   next
 76ASP程序运行速度测试ttt2=now()
 77ASP程序运行速度测试tou=ttt2-ttt1
 78ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&"<br>"
 79ASP程序运行速度测试next
 80ASP程序运行速度测试
 81ASP程序运行速度测试txt=""
 82ASP程序运行速度测试for sn=0 to 5
 83ASP程序运行速度测试ttt1=now()
 84ASP程序运行速度测试  txt=""
 85ASP程序运行速度测试   for i=0 to 20000
 86ASP程序运行速度测试          txt="aa"&txt
 87ASP程序运行速度测试   next
 88ASP程序运行速度测试ttt2=now()
 89ASP程序运行速度测试tou=ttt2-ttt1
 90ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&"<br>"
 91ASP程序运行速度测试next
 92ASP程序运行速度测试
 93ASP程序运行速度测试%>
 94ASP程序运行速度测试用FOR 循环比DO  WHILE循环要快得多,用下面的程序测试,虽然FOR循环中要多一个变量,
 95ASP程序运行速度测试<%
 96ASP程序运行速度测试dim tttt1,ttt2
 97ASP程序运行速度测试
 98ASP程序运行速度测试for sn=0 to 5
 99ASP程序运行速度测试ttt1=now()
100ASP程序运行速度测试  i=0
101ASP程序运行速度测试   do while i<=100000
102ASP程序运行速度测试      i=i+1
103ASP程序运行速度测试   loop
104ASP程序运行速度测试ttt2=now()
105ASP程序运行速度测试tou=ttt2-ttt1
106ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&"<br>"
107ASP程序运行速度测试next
108ASP程序运行速度测试
109ASP程序运行速度测试for sn=0 to 5
110ASP程序运行速度测试ttt1=now()
111ASP程序运行速度测试   ii=0
112ASP程序运行速度测试   for i=0 to 100000
113ASP程序运行速度测试    ii=ii+1
114ASP程序运行速度测试   next
115ASP程序运行速度测试ttt2=now()
116ASP程序运行速度测试tou=ttt2-ttt1
117ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&"<br>"
118ASP程序运行速度测试next
119ASP程序运行速度测试%>
120ASP程序运行速度测试定义5000个一个字符的SESSION并不比定义5000个有5000个字符串长的SESSION少花很多时间,两者时间差仅为近一倍,用一秒多钟。倒是生成这个5000个字符长的变量花了不少的时间,<%
121ASP程序运行速度测试dim tttt1,ttt2
122ASP程序运行速度测试c="a"
123ASP程序运行速度测试for sn=0 to 5
124ASP程序运行速度测试
125ASP程序运行速度测试session.abandon
126ASP程序运行速度测试ttt1=now()
127ASP程序运行速度测试   for i=0 to 5000
128ASP程序运行速度测试       session("s"&i)=c
129ASP程序运行速度测试    next
130ASP程序运行速度测试ttt2=now()
131ASP程序运行速度测试tou=ttt2-ttt1
132ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&":"&session("s"&i-1)&"<br>"
133ASP程序运行速度测试next
134ASP程序运行速度测试
135ASP程序运行速度测试for i=0 to 5000
136ASP程序运行速度测试  c="a"&c
137ASP程序运行速度测试next
138ASP程序运行速度测试
139ASP程序运行速度测试for sn=0 to 5
140ASP程序运行速度测试session.abandon
141ASP程序运行速度测试ttt1=now()
142ASP程序运行速度测试   for i=0 to 5000
143ASP程序运行速度测试       session("s"&i)=c
144ASP程序运行速度测试    next
145ASP程序运行速度测试ttt2=now()
146ASP程序运行速度测试tou=ttt2-ttt1
147ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&":"  &session("s"&i-1)&"<br>"
148ASP程序运行速度测试next
149ASP程序运行速度测试
150ASP程序运行速度测试
151ASP程序运行速度测试%>
152ASP程序运行速度测试
153ASP程序运行速度测试
154ASP程序运行速度测试这段程序从SN=3起就很慢,而前面非常快
155ASP程序运行速度测试<!--#include file="filetou.asp"-->
156ASP程序运行速度测试<%
157ASP程序运行速度测试dim tttt1,ttt2
158ASP程序运行速度测试for sn=0 to 5
159ASP程序运行速度测试ttt1=now()
160ASP程序运行速度测试  for i=1 to  20
161ASP程序运行速度测试   sql ="SELECT 名称  from user where 名称='阿余'"
162ASP程序运行速度测试   Set rs=Server.CreateObject("ADODB.RecordSet")                        
163ASP程序运行速度测试   rs.Open sql,conn,1,3
164ASP程序运行速度测试   rs("名称")="阿余"
165ASP程序运行速度测试   rs.update
166ASP程序运行速度测试   rs.close
167ASP程序运行速度测试next
168ASP程序运行速度测试ttt2=now()
169ASP程序运行速度测试tou=ttt2-ttt1
170ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&":"&session("s"&i-1)&"<br>"
171ASP程序运行速度测试next
172ASP程序运行速度测试
173ASP程序运行速度测试
174ASP程序运行速度测试%>
175ASP程序运行速度测试
176ASP程序运行速度测试
177ASP程序运行速度测试而这样就快多了。看来建对象很要花些时间,还有,用MOVE 0,1 和  MOVEFIRST 相比速度没有什么差别。
178ASP程序运行速度测试<!--#include file="filetou.asp"-->
179ASP程序运行速度测试<%
180ASP程序运行速度测试   sql ="SELECT 名称  from user where 名称='阿余'"
181ASP程序运行速度测试   Set rs=Server.CreateObject("ADODB.RecordSet")                        
182ASP程序运行速度测试   rs.Open sql,conn,1,3
183ASP程序运行速度测试dim tttt1,ttt2 
184ASP程序运行速度测试for sn=0 to 5
185ASP程序运行速度测试ttt1=now()
186ASP程序运行速度测试  for i=1 to  700
187ASP程序运行速度测试   rs("名称")="阿余"
188ASP程序运行速度测试   rs.update
189ASP程序运行速度测试   rs.movefirst
190ASP程序运行速度测试next
191ASP程序运行速度测试ttt2=now()
192ASP程序运行速度测试tou=ttt2-ttt1
193ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&":"&session("s"&i-1)&"<br>"
194ASP程序运行速度测试next
195ASP程序运行速度测试%>
196ASP程序运行速度测试
197ASP程序运行速度测试而这两种方式相比,后者要慢3倍,可能是后者要重新查询,但比前面的用RS建查询后又去改,改了又关,相比,要快了不知多少。
198ASP程序运行速度测试<!--#include file="filetou.asp"-->
199ASP程序运行速度测试<%
200ASP程序运行速度测试   sql ="SELECT 名称  from user where 名称='阿余'"
201ASP程序运行速度测试   Set rs=Server.CreateObject("ADODB.RecordSet")                        
202ASP程序运行速度测试   rs.Open sql,conn,1,3
203ASP程序运行速度测试dim tttt1,ttt2 
204ASP程序运行速度测试
205ASP程序运行速度测试for sn=0 to 5
206ASP程序运行速度测试ttt1=now()
207ASP程序运行速度测试  for i=1 to  700
208ASP程序运行速度测试   rs("名称")="阿余"
209ASP程序运行速度测试   rs.update
210ASP程序运行速度测试   rs.movefirst
211ASP程序运行速度测试next
212ASP程序运行速度测试ttt2=now()
213ASP程序运行速度测试tou=ttt2-ttt1
214ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&":"&session("s"&i-1)&"<br>"
215ASP程序运行速度测试next
216ASP程序运行速度测试
217ASP程序运行速度测试for sn=0 to 5
218ASP程序运行速度测试ttt1=now()
219ASP程序运行速度测试  for i=1 to  700
220ASP程序运行速度测试     SQL="UPDATE user set 名称='阿余'  where 名称='阿余'"
221ASP程序运行速度测试     conn.execute sql,0,-1
222ASP程序运行速度测试next
223ASP程序运行速度测试ttt2=now()
224ASP程序运行速度测试tou=ttt2-ttt1
225ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&":"&session("s"&i-1)&"<br>"
226ASP程序运行速度测试next
227ASP程序运行速度测试
228ASP程序运行速度测试%>
229ASP程序运行速度测试
230ASP程序运行速度测试
231ASP程序运行速度测试新加一万条记录谁快?第一种方法用31秒,后者直到超时仍未完成。不得已,少掉一个0,1000条是,后者慢一半。
232ASP程序运行速度测试<!--#include file="filetou.asp"-->
233ASP程序运行速度测试<%
234ASP程序运行速度测试   sql ="SELECT 名称  from user where id=0"
235ASP程序运行速度测试   Set rs=Server.CreateObject("ADODB.RecordSet")                        
236ASP程序运行速度测试   rs.Open sql,conn,1,3
237ASP程序运行速度测试dim tttt1,ttt2 
238ASP程序运行速度测试
239ASP程序运行速度测试ttt1=now()
240ASP程序运行速度测试  for i=1 to  10000
241ASP程序运行速度测试   rs.addnew
242ASP程序运行速度测试   rs("名称")="阿余A"
243ASP程序运行速度测试   rs.update
244ASP程序运行速度测试next
245ASP程序运行速度测试ttt2=now()
246ASP程序运行速度测试tou=ttt2-ttt1
247ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&":"&session("s"&i-1)&"<br>"
248ASP程序运行速度测试
249ASP程序运行速度测试
250ASP程序运行速度测试ttt1=now()
251ASP程序运行速度测试  for i=1 to  10000
252ASP程序运行速度测试     sql=" INSERT INTO  user (名称) VALUES('阿余B')"
253ASP程序运行速度测试     conn.execute sql,0,-1
254ASP程序运行速度测试next
255ASP程序运行速度测试ttt2=now()
256ASP程序运行速度测试tou=ttt2-ttt1
257ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&":"&session("s"&i-1)&"<br>"
258ASP程序运行速度测试
259ASP程序运行速度测试
260ASP程序运行速度测试%>
261ASP程序运行速度测试
262ASP程序运行速度测试下面的程序结果说明RS新增记录较快,而删除较慢,用CONN新增慢,但删除很快。
263ASP程序运行速度测试运行的结果为:
264ASP程序运行速度测试3.00000007264316:
265ASP程序运行速度测试7.99999998416752:
266ASP程序运行速度测试1.99999983888119:
267ASP程序运行速度测试0:
268ASP程序运行速度测试后来用RS新增记录5000条,并用CONN删除这5000条, 结果为:
269ASP程序运行速度测试17.000000202097:
270ASP程序运行速度测试1.00000023376197:
271ASP程序运行速度测试程序为:
272ASP程序运行速度测试<!--#include file="filetou.asp"-->
273ASP程序运行速度测试<%
274ASP程序运行速度测试dim tttt1,ttt2 
275ASP程序运行速度测试ttt1=now()
276ASP程序运行速度测试sql ="SELECT 名称  from user where id=0"
277ASP程序运行速度测试   Set rs=Server.CreateObject("ADODB.RecordSet")                        
278ASP程序运行速度测试   rs.Open sql,conn,1,3
279ASP程序运行速度测试  for i=1 to  1000
280ASP程序运行速度测试   rs.addnew
281ASP程序运行速度测试   rs("名称")="阿余A"
282ASP程序运行速度测试   rs.update
283ASP程序运行速度测试next
284ASP程序运行速度测试ttt2=now()
285ASP程序运行速度测试tou=ttt2-ttt1
286ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&":"&session("s"&i-1)&"<br>"
287ASP程序运行速度测试
288ASP程序运行速度测试
289ASP程序运行速度测试ttt1=now()
290ASP程序运行速度测试  for i=1 to  1000
291ASP程序运行速度测试     sql=" INSERT INTO  user (名称) VALUES('阿余B')"
292ASP程序运行速度测试     conn.execute sql,0,-1
293ASP程序运行速度测试next
294ASP程序运行速度测试ttt2=now()
295ASP程序运行速度测试tou=ttt2-ttt1
296ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&":"&session("s"&i-1)&"<br>"
297ASP程序运行速度测试
298ASP程序运行速度测试
299ASP程序运行速度测试
300ASP程序运行速度测试
301ASP程序运行速度测试ttt1=now()
302ASP程序运行速度测试   sql ="SELECT  名称 from user where 名称='阿余A'"
303ASP程序运行速度测试   Set rs=Server.CreateObject("ADODB.RecordSet")                        
304ASP程序运行速度测试   rs.Open sql,conn,1,3
305ASP程序运行速度测试do while not rs.eof
306ASP程序运行速度测试   rs.delete
307ASP程序运行速度测试   rs.update
308ASP程序运行速度测试   rs.move 0,1
309ASP程序运行速度测试  loop
310ASP程序运行速度测试ttt2=now()
311ASP程序运行速度测试tou=ttt2-ttt1
312ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&":"&session("s"&i-1)&"<br>"
313ASP程序运行速度测试
314ASP程序运行速度测试
315ASP程序运行速度测试ttt1=now()
316ASP程序运行速度测试   sql ="delete from user  where 名称='阿余B'"
317ASP程序运行速度测试    conn.execute sql,0,-1
318ASP程序运行速度测试ttt2=now()
319ASP程序运行速度测试tou=ttt2-ttt1
320ASP程序运行速度测试Response.Write sn&""&tou*24*60*60&":"&session("s"&i-1)&"<br>"
321ASP程序运行速度测试%> 

相关文章: