三、第一次测试
在第一次测试中,我们模拟microsoft asp ado示例中可找到的典型情形提取一个记录集。在这个例子(ado__01.asp)中,我们首先打开一个连接,然后创建记录集对象。当然,这里的脚本按照本文第一部分所总结的编码规则作了优化。
< % option explicit % >
< !– #include file="adovbs.inc" — >
< %
dim objconn
dim objrs
response.write( _
"< html >< head >" & _
"< title >ado test< /title >" & _
"< /head >< body >" _
)
set objconn = server.createobject("adodb.connection")
objconn.open application("conn")
set objrs = server.createobject("adodb.recordset")
objrs.activeconnection = objconn
objrs.cursortype = adopenforwardonly
objrs.locktype = adlockreadonly
objrs.open application("sql")
if objrs.eof then
response.write("no records found")
else
write headings
response.write( _
"< table border=1 >" & _
"< tr >" & _
"< th >orderid< /th >" & _
"< th >customerid< /th >" & _
"< th >employeeid< /th >" & _
"< th >orderdate< /th >" & _
"< th >requireddate< /th >" & _
"< th >shippeddate< /th >" & _
"< th >freight< /th >" & _
"< /tr >" _
)
write data
do while not objrs.eof
response.write( _
"< tr >" & _
"< td >" & objrs("orderid") & "< /td >" & _
"< td >" & objrs("customerid") & "< /td >" & _
"< td >" & objrs("employeeid") & "< /td >" & _
"< td >" & objrs("orderdate") & "< /td >" & _
"< td >" & objrs("requireddate") & "< /td >" & _
"< td >" & objrs("shippeddate") & "< /td >" & _
"< td >" & objrs("freight") & "< /td >" & _
"< /tr > " _
)
objrs.movenext
loop
response.write("< /table >")
end if
objrs.close
objconn.close
set objrs = nothing
set objconn = nothing
response.write("< /body >< /html >")
% >
下面是测试结果:
我们来看一下各栏数字的含义: 0 返回0个记录的页面所需要的ttlb(毫秒)。在所有的测试中,该值被视为生成页面本身(包括创建对象)的时间开销,不包含循环访问记录集数据的时间。
25 以毫秒计的提取和显示25个记录的ttlb。
tot time/25 "25"栏的ttlb除以25,它是每个记录的总计平均时间开销。
disp time/25 "25"栏的ttlb减去"0"栏的ttlb,然后除以25。该值反映了在循环记录集时显示单个记录所需时间。
250 提取和显示250个记录的ttlb。
tot time/250 "250"栏的ttlb除以25,该值代表单个记录的总计平均时间开销。
disp time/250 "250"栏的ttlb减去"0"栏的ttlb,再除以250。该值反映了在循环记录集时显示单个记录所需时间。
上面的测试结果将用来同下一个测试结果比较。
