ASP程序运行速度测试

news/2025/2/23 15:27:21
1 程序运行速度试验结果:
2 1 。作相同的分支条件判断: IF 比SELECT慢。
3 用以下程序测试:
4 < %
5 dim tttt1,ttt2
6 session( " ii " ) = 0
7 for sn = 0 to 5
8 ttt1 = now ()
9 for i = 0 to 300000
10 if session( " ii " ) = 0 then
11 session( " ii " ) = 1
12 else
13 if session( " ii " ) = 1 then
14 session( " ii " ) = 2
15 else
16 if session( " ii " ) = 2 then
17 session( " ii " ) = 3
18 else
19 session( " ii " ) = 0
20 end if
21 end if
22 end if
23 next
24 ttt2 = now ()
25 tou = ttt2 - ttt1
26 Response.Writesn & " " & tou * 24 * 60 * 60 & " <br>"
27 next
28
29 for sn = 0 to 5
30 ttt1 = now ()
31 for i = 0 to 300000
32 select case session( " ii " )
33 case 0
34 session( " ii " ) = 1
35 case 1
36 session( " ii " ) = 2
37 case 2
38 session( " ii " ) = 3
39 case 3
40 session( " ii " ) = 0
41 end select
42 next
43 ttt2 = now ()
44 tou = ttt2 - ttt1
45 Response.Writesn & " " & tou * 24 * 60 * 60 & " <br>"
46 next
47
48 % >
49 2 ,如果把上例中的SESSION对象改为用普通的变量存。速度会快差不多8倍
50 3 ,进行字符串连接时往中间加入相同多的字符串,基数越大,越慢。
51 通过下面的程序测试:
52 < %
53 dim tttt1,ttt2
54 session( " ii " ) = 0
55 for sn = 0 to 5
56 ttt1 = now ()
57 ' txt=""
58 for i = 0 to 10000
59 txt = " a " & txt
60 next
61 ttt2 = now ()
62 tou = ttt2 - ttt1
63 Response.Writesn & " " & tou * 24 * 60 * 60 & " <br>"
64 next
65 % >
66 进行同样长字节的字符连接时,汉字比英文快4倍,通过下面的程序测试
67 < %
68
69 dim tttt1,ttt2
70 for sn = 0 to 5
71 ttt1 = now ()
72 txt = " "
73 for i = 0 to 20000
74 txt = " " & txt
75 next
76 ttt2 = now ()
77 tou = ttt2 - ttt1
78 Response.Writesn & " " & tou * 24 * 60 * 60 & " <br>"
79 next
80
81 txt = " "
82 for sn = 0 to 5
83 ttt1 = now ()
84 txt = " "
85 for i = 0 to 20000
86 txt = " aa " & txt
87 next
88 ttt2 = now ()
89 tou = ttt2 - ttt1
90 Response.Writesn & " " & tou * 24 * 60 * 60 & " <br>"
91 next
92
93 % >
94 用FOR循环比DOWHILE循环要快得多,用下面的程序测试,虽然FOR循环中要多一个变量,
95 < %
96 dim tttt1,ttt2
97
98 for sn = 0 to 5
99 ttt1 = now ()
100 i = 0
101 do while i <= 100000
102 i = i + 1
103 loop
104 ttt2 = now ()
105 tou = ttt2 - ttt1
106 Response.Writesn & " " & tou * 24 * 60 * 60 & " <br>"
107 next
108
109 for sn = 0 to 5
110 ttt1 = now ()
111 ii = 0
112 for i = 0 to 100000
113 ii = ii + 1
114 next
115 ttt2 = now ()
116 tou = ttt2 - ttt1
117 Response.Writesn & " " & tou * 24 * 60 * 60 & " <br>"
118 next
119 % >
120 定义5000个一个字符的SESSION并不比定义5000个有5000个字符串长的SESSION少花很多时间,两者时间差仅为近一倍,用一秒多钟。倒是生成这个5000个字符长的变量花了不少的时间, < %
121 dim tttt1,ttt2
122 c = " a"
123 for sn = 0 to 5
124
125 session.abandon
126 ttt1 = now ()
127 for i = 0 to 5000
128 session( " s " & i) = c
129 next
130 ttt2 = now ()
131 tou = ttt2 - ttt1
132 Response.Writesn & " " & tou * 24 * 60 * 60 & " : " & session( " s " & i - 1 ) & " <br>"
133 next
134
135 for i = 0 to 5000
136 c = " a " & c
137 next
138
139 for sn = 0 to 5
140 session.abandon
141 ttt1 = now ()
142 for i = 0 to 5000
143 session( " s " & i) = c
144 next
145 ttt2 = now ()
146 tou = ttt2 - ttt1
147 Response.Writesn & " " & tou * 24 * 60 * 60 & " : " & session( " s " & i - 1 ) & " <br>"
148 next
149
150
151 % >
152
153
154 这段程序从SN=3起就很慢,而前面非常快
155 < ! -- #includefile = " filetou.asp " -->
156 < %
157 dim tttt1,ttt2
158 for sn = 0 to 5
159 ttt1 = now ()
160 for i = 1 to 20
161 sql = " SELECT名称fromuserwhere名称='阿余'"
162 Set rs = Server. CreateObject ( " ADODB.RecordSet " )
163 rs.Opensql,conn, 1 , 3
164 rs( " 名称 " ) = " 阿余"
165 rs.update
166 rs.close
167 next
168 ttt2 = now ()
169 tou = ttt2 - ttt1
170 Response.Writesn & " " & tou * 24 * 60 * 60 & " : " & session( " s " & i - 1 ) & " <br>"
171 next
172
173
174 % >
175
176
177 而这样就快多了。看来建对象很要花些时间,还有,用MOVE 0 , 1 和MOVEFIRST相比速度没有什么差别。
178 < ! -- #includefile = " filetou.asp " -->
179 < %
180 sql = " SELECT名称fromuserwhere名称='阿余'"

http://www.niftyadmin.cn/n/604638.html

相关文章

Jenkins集成liferay项目__ant版

ant脚本配置liferay-portlet项目jenkins构建一、检出主服务器项目并import到本地svn服务器暂更改名称为liferayManage_zhong二、更改配置文件1、build.xml(添加sdk.path全局属性)sdk.path为你的liferay sdk位置<project name"liferayManage-portlet" basedir"…

iphone型号表_中屏、大屏、特大屏,您要点哪屏 iPhone ?

iPhone今年已经连续降价4轮了&#xff0c;还没买的小伙伴们是不是早就在观望了&#xff1f;只是iPhone屏幕尺寸花样越来越多&#xff0c;到底怎么选&#xff1f;在星巴克点咖啡总是对店员建议升杯的吆喝烦恼不已&#xff0c;苹果也用上了这种营销套路&#xff0c;一次出了三款手…

fpga8个按键控制8个led灯亮和灭_FPGA入门系列10按键消抖

文章简介本系列文章主要针对FPGA初学者编写&#xff0c;包括FPGA的模块书写、基础语法、状态机、RAM、UART、SPI、VGA、以及功能验证等。将每一个知识点作为一个章节进行讲解&#xff0c;旨在更快速的提升初学者在FPGA开发方面的能力&#xff0c;每一个章节中都有针对性的代码书…

犯了个低级错误

今天装oracle 11g&#xff0c;单实例。安装居然一直不能配置监听器&#xff0c;导致创建数据库不能继续下去。卸载、重装还是这个样子。仔细检查&#xff0c;居然是/etc/sysconfig/network与/etc/hosts里的主机名字不一致&#xff08;一个是dbserve,一个是dbsever&#xff09;,…

显示一个Form中的所有内容

1如果想把上个网页<Form>..</Form>内的所有内容显示出来&#xff0c;有这样两种方法&#xff1a;231、以ForEach..In..45<%6ForEachNameInRequest.Form7Response.Write("<Br>"&Name&"")8Response.Write(Request.Form(Name))9…

将vscode变成C++ IDE

友链 首先你需要安装visual stdio&#xff0c;随便什么版本装上就行&#xff0c;不在乎是收费的还是不收费的创建文件夹 mkdir "C:\Users\x\Documents\Visual Studio 2012\Projects\ConsoleApplication1\ConsoleApplication1" 进入该目录 cd "C:\Users\x\Docum…

kettle性能及效率提升_辽宁公司探索系统化推进资源池效率提升“六步工作法”初见成效...

国家提速降费的大背景下&#xff0c;面对市场竞争激烈&#xff0c;有效控制成本转换为竞争优势&#xff0c;集团公司对降本增效工作做了全面部署&#xff0c;要求牢固树立“一切成本皆可控”及“勤俭办企业”理念&#xff0c;系统推进低效无效资产清理工作。为更好地贯彻落实集…

手机游戏开发综述

一、背景介绍 现在的移动电话是小型的计算机&#xff0c;它的处理能力与台式机的标准处理能力相比很有限&#xff0c;但是足够运行一个小型的游戏。 现在的手机的一个特性就是它们还是网络计算机&#xff0c;能够高速发送和接收数字数据。 除了语音数据以外&#xff0c;它们还…