<% ' Standard stuff for making database connections, etc. %>
<% ' The timing class library. You'll need to add this to your code. %>
<%
' Create a timing context for doing timing tests.
Dim sl_timer
Set sl_timer = new SlTimerContext
' All possible methods for getting the recordset.
Dim rs_methods
rs_methods = Array("firehose", "static", "client") ', "keyset", "dynamic")
' The current method for getting the recordset.
' Referred to by the GetRecordset function below.
Dim gRsMethod
' Local testing variables.
Dim strXML
Dim rs
' Loop over the recordset computing methods timing each of the XML generation methods.
Dim rs_method
for each rs_method in rs_methods
' Set the current method for getting the recordset.
gRsMethod = rs_method
' Test the various RsToXML methods.
' You call the EnterScope and ExitScope methods with the same descriptive string
' and this is what shows up in the report that is generated.
' Note that each of the timings only measures time taken by the XML generation,
' not by the recordset fetching.
' This makes the results more meaningful for comparing the different methods,
' but less applicable to "the real world" because the database work to get the recordset
' is often the main source of slowdowns.
Set rs = GetRs
sl_timer.EnterScope gRsMethod & "_orig"
strXML = ConvertRStoXML_original(rs, "orders", "order")
sl_timer.ExitScope gRsMethod & "_orig"
rs.Close
Set rs = nothing
'DebugLine "Len(strXML)", Len(strXML)
Set rs = GetRs
sl_timer.EnterScope gRsMethod & "_july"
strXML = ConvertRStoXML_01july(rs, "orders", "order")
sl_timer.ExitScope gRsMethod & "_july"
rs.Close
Set rs = nothing
'DebugLine "Len(strXML)", Len(strXML)
Set rs = GetRs
sl_timer.EnterScope gRsMethod & "_v2"
strXML = ConvertRStoXML2(rs, "orders", "order").xml
sl_timer.ExitScope gRsMethod & "_v2"
rs.Close
Set rs = nothing
'DebugLine "Len(strXML)", Len(strXML)
Set rs = GetRs
sl_timer.EnterScope gRsMethod & "_v3"
strXml = ConvertRStoXML3(rs, "orders", "order").xml
sl_timer.ExitScope gRsMethod & "_v3"
'DebugLine "Len(strXML)", Len(strXML)
Set rs = GetRs
sl_timer.EnterScope gRsMethod & "_v3_vb"
Dim sql_utils
Set sql_utils = Server.CreateObject("SlGenUtils.SqlUtils")
strXml = sql_utils.ConvertRStoXML3(rs, "orders", "order").xml
Set sql_utils = nothing
sl_timer.ExitScope gRsMethod & "_v3_vb"
'DebugLine "Len(strXML)", Len(strXML)
Set rs = GetRs
Randomize
Dim dest_path
dest_path = Server.MapPath("persistedRS" & Rnd & ".xml")
Dim fs
Set fs = GetFs
if fs.FileExists(dest_path) then
fs.DeleteFile dest_path
end if
sl_timer.EnterScope gRsMethod & "_save"
rs.Save dest_path, adPersistXML
strXml = fs.OpenTextFile(dest_path).ReadAll
fs.DeleteFile dest_path
Set fs = nothing
sl_timer.ExitScope gRsMethod & "_save"
rs.Close
Set rs = nothing
'DebugLine "Len(strXML)", Len(strXML)
Set rs = GetRs
sl_timer.EnterScope gRsMethod & "_save_xml"
Dim objXMLDom
Set objXMLDom = Server.CreateObject("Microsoft.XMLDOM")
rs.Save objXMLDom, adPersistXML
strXml = objXMLDom.xml
Set objXMLDom = nothing
sl_timer.ExitScope gRsMethod & "_save_xml"
rs.Close
Set rs = nothing
'DebugLine "Len(strXML)", Len(strXML)
next
' Output a report on the timings of the various methods.
SummarizeTiming sl_timer
' Method to get one recordset out.
function GetRs
Dim sql
sql = "SELECT TOP 100 * FROM Files WITH (NOLOCK)"
Dim rs
select case gRsMethod
case "static"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, DatabaseConnection, adOpenStatic ' , adLockReadOnly
case "client"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = adUseClient
rs.Open sql, DatabaseConnection, adOpenStatic ' , adLockReadOnly
case "keyset"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = adUseClient
rs.Open sql, DatabaseConnection, adOpenKeyset, adLockPessimistic
case "dynamic"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = adUseClient
rs.Open sql, DatabaseConnection, adOpenDynamic, adLockPessimistic
case else ' "firehose"
Set rs = DatabaseConnection.Execute(sql)
end select
Set GetRs = rs
end function
%>