1
程序运行速度试验结果:
2
1。作相同的分支条件判断:IF比SELECT慢。
3
用以下程序测试:
4
<%
5
dimtttt1,ttt2
6
session("ii")=0
7
forsn=0to5
8
ttt1=now()
9
fori=0to300000
10
ifsession("ii")=0then
11
session("ii")=1
12
else
13
ifsession("ii")=1then
14
session("ii")=2
15
else
16
ifsession("ii")=2then
17
session("ii")=3
18
else
19
session("ii")=0
20
endif
21
endif
22
endif
23
next
24
ttt2=now()
25
tou=ttt2-ttt1
26
Response.Writesn&"、"&tou*24*60*60&"<br>"
27
next
28
29
forsn=0to5
30
ttt1=now()
31
fori=0to300000
32
selectcasesession("ii")
33
case0
34
session("ii")=1
35
case1
36
session("ii")=2
37
case2
38
session("ii")=3
39
case3
40
session("ii")=0
41
endselect
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
dimtttt1,ttt2
54
session("ii")=0
55
forsn=0to5
56
ttt1=now()
57
'txt=""
58
fori=0to10000
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
dimtttt1,ttt2
70
forsn=0to5
71
ttt1=now()
72
txt=""
73
fori=0to20000
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
forsn=0to5
83
ttt1=now()
84
txt=""
85
fori=0to20000
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
dimtttt1,ttt2
97
98
forsn=0to5
99
ttt1=now()
100
i=0
101
dowhilei<=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
forsn=0to5
110
ttt1=now()
111
ii=0
112
fori=0to100000
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
dimtttt1,ttt2
122
c="a"
123
forsn=0to5
124
125
session.abandon
126
ttt1=now()
127
fori=0to5000
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
fori=0to5000
136
c="a"&c
137
next
138
139
forsn=0to5
140
session.abandon
141
ttt1=now()
142
fori=0to5000
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
dimtttt1,ttt2
158
forsn=0to5
159
ttt1=now()
160
fori=1to20
161
sql="SELECT名称fromuserwhere名称='阿余'"
162
Setrs=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
而这样就快多了。看来建对象很要花些时间,还有,用MOVE0,1和MOVEFIRST相比速度没有什么差别。
178
<!--#includefile="filetou.asp"-->
179
<%
180
sql="SELECT名称fromuserwhere名称='阿余'"

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180
