Program | Performance three, first time test
In the first test, we simulated a typical scenario found in the Microsoft ASP ADO sample to extract a Recordset. In this example (ado__01.asp), we first open a connection and then create the Recordset object. Of course, the scripts here are optimized according to the coding rules summarized in the first part of this article.
<% Option Explicit% >
<!--#Include file= "Adovbs. INC "->
<%
Dim objconn
Dim objRS
Response.Write (_
"< HTML >< head >" & _
"< TITLE >ado test</title >" & _
")
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 as 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 >% >
Here is the test result:
Let's take a look at the meaning of each column number:
0 returns the ttlb (milliseconds) required for a 0-record page. In all tests, this value is considered to be the time cost of generating the page itself, including the creation of an object, and does not contain the time to iterate over the recordset data.
25 ttlb with 25 records extracted and displayed in milliseconds
The tot time/25 "25" column ttlb divided by 25, which is the total average time cost for each record.
Disp TIME/25 The ttlb of the "25" column minus the ttlb of the "0" column, then divided by 25. This value reflects the time it takes to display a single record when the Recordset is being cycled.
250 extract and display the ttlb of 250 records.
The tot time/250 "250" column ttlb divided by 25, which represents the total average time cost for a single record.
Disp time/250 the "250" column of the Ttlb minus the "0" column ttlb, divided by 250. This value reflects the time it takes to display a single record when the Recordset is being cycled.
The test results above will be used to compare with the next test result.