Karl Blessing
Programmer
right now I've managed to get my page to load in an averaging 3-7 second, as opposed to 13-20 seconds that I had it at before, I have done this to increase the speed, by loading all common recordsets into an array<br><br><FONT FACE=monospace><font color=blue><br><% @Language=VBScript %><br><% <br>Response.Buffer = True <br>Response.Write Time() & vbcrlf<br>%><br><!--<#include file="..\functions3.inc">--><br><!--<#include file="..\constants.inc">--><br><%<br>Response.Write "<html>" & vbcrlf & "<head></head>" & vbcrlf & "<body " & gLBgcolor & ">"<br>'<!-- Constants, globals, declarations --><br>Const HID = 0<br>Const LID = 1<br>Const Name = 2<br>Const RType = 3<br>Const Value = 4<br>Const Label = 5<br>Const HP = 6<br>Const LP = 7<br><br>Const LangID = 0<br>Const LangTab = 1<br>Const LangRadio = 2<br>Const LangType = 3<br><br>Dim Change<br>Change = True<br>Dim HTMLStr<br>Dim HTMLStr1<br>Dim Count<br>Dim Spaces<br>Count = 0<br>Spaces = 0<br><br>HTMLStr = ""<br>HTMLStr1 = ""<br><br>Dim RS<br>Dim Conn<br>Dim LangData<br>Dim AryData<br><br>Set Conn = Server.CreateObject("ADODB.Connection"<br>Set RS = Server.CreateObject("ADODB.Recordset"<br>'Array Loading (Increase added by KJB 7/19/00)<br>'Results : cut wasted performance down by half, now averages 4-7 seconds, as opposed to 13-20 seconds<br><br>Set objDB = WebConn()<br><br>Dim ESA<br>Dim ESA2<br>Set ESA2 = objDB.EsDataGroup(1)<br>ESA = ESA2.GetRows()<br>ESA2.Close<br>Set ESA2 = nothing<br><br>Dim RM<br>Dim RM2<br>Set RM2 = objDB.ProgCompGroup(1)<br>RM = RM2.GetRows()<br>RM2.Close<br>Set RM2 = nothing<br><br>Dim Occ<br>Dim Occ2<br>Set Occ2 = objDB.OescodeGroups<br>Occ = Occ2.GetRows<br>Occ2.Close<br>Set Occ2 = nothing<br><br>Dim IOC<br>Dim IOC2<br>Set IOC2 = objDB.Sicdiv()<br>IOC = IOC2.GetRows()<br>IOC2.Close<br>set IOC2 = nothing<br><br>WebDisConn(objDB)<br><br>Conn.Open "Tree", "sa", ""<br>RS.Open "SELECT Tree.HID, Tree.ID, Tree.Name, InputType.Type, Tree.Val, Tree.Label, Tree.HParent, Tree.LParent FROM Tree INNER JOIN InputType ON Tree.Type = InputType.ID order by Tree.HID, Tree.ID",Conn, 0,1<br>If not RS.EOF then<br> AryData = RS.GetRows<br> RS.Close<br>end if<br>RS.Open "Select * from LanguageLabel",Conn, 0,1<br>If not RS.EOF then<br> LangData = RS.GetRows<br> RS.Close<br>end if<br>Set RS = nothing<br>Conn.Close<br>Set Conn = nothing<br><br>'end Array Loading<br></font></font><br><i>AryData has always been there even when it was 13seconds, the increase is by loading those 4 things above into an array , you'll see why in this next function</i><br><FONT FACE=monospace><font color=blue><br>'<!-- Rescursive Subroutine with starting point --><br>sub showtreeat(byref theObj, HpLoc, LpLoc)<br> Dim TreeRow<br> TreeRow = UBound(theObj, 2)<br> for j = 0 to TreeRow<br> If theObj(HP,j) = HpLoc and theObj(LP,j) = LpLoc then<br> if Change = true then <br> If Spaces = 0 then<br> If count > 45 then<br> Change = False<br> HTMLStr1 = HTMLStr<br> HTMLStr = ""<br> end if<br> end if<br> end if<br> if theObj(RType,j) <> "DataGroup" then<br> If Spaces = 0 then<br> HTMLStr = HTMLStr & "<TR><TD " & gHeader2CellColor & ">"<br> else<br> HTMLStr = HTMLStr & "<TR><TD " & gTableCellColor & ">"<br> end if<br> writetabs(Spaces)<br> HTMLStr = HTMLStr & vbcrlf & "<input type=""" & TheObj(RType, j) & """ name=""" & TheObj(Name, j) & """ value=""" & TheObj(Value,j) & """>"<br> HTMLStr = HTMLStr & TheObj(Label, j) <br> HTMLStr = HTMLStr & "</TD></TR>" & vbcrlf & vbcrlf<br> Count = Count + 1<br> else<br><font color=red> select case theObj(Label,j)<br> case "ESA"<br> for esloop = LBound(ESA,2) to UBound(ESA,2)<br> HTMLStr = HTMLStr & "<TR><TD " & gTableCellColor & ">"<br> writetabs(Spaces)<br> HTMLStr = HTMLStr & vbcrlf & "<input type=""" & TheObj(Value, j) & """ name=""" & theObj(HID,j) & "_code"" value=""" & Trim(ESA(1,esloop)) & "~" & Trim(ESA(2,esloop)) & """>"<br> HTMLStr = HTMLStr & ESA(3,esloop) & "</TD></TR>" & vbcrlf & vbcrlf<br> Count = Count + 1<br> next<br> case "RM"<br> for rmloop = LBound(RM,2) to UBound(RM,2)<br> HTMLStr = HTMLStr & "<TR><TD " & gTableCellColor & ">"<br> writetabs(Spaces)<br> HTMLStr = HTMLStr & vbcrlf & "<input type=""" & TheObj(Value, j) & """ name=""" & theObj(HID,j) & "_code"" value=""" & Trim(RM(1,rmloop)) & "~" & Trim(RM(2,rmloop)) & """>"<br> HTMLStr = HTMLStr & RM(3,rmloop) & "</TD></TR>" & vbcrlf & vbcrlf<br> Count = Count + 1<br> next<br> case "O"<br> for oloop = LBound(Occ,2) to UBound(Occ,2)<br> HTMLStr = HTMLStr & "<TR><TD " & gTableCellColor & ">"<br> writetabs(Spaces)<br> HTMLStr = HTMLStr & vbcrlf & "<input type=""" & TheObj(Value, j) & """ name=""" & theObj(HID,j) & "_code"" value=""" & Occ(0,oloop) & """>"<br> HTMLStr = HTMLStr & Occ(1,oloop) & vbcrlf & "</TD></TR>" & vbcrlf & vbcrlf<br> Count = Count + 1<br> next<br> case "IOC"<br> for iloop = LBound(IOC,2) to UBound(IOC,2)<br> HTMLStr = HTMLStr & "<TR><TD " & gTableCellColor & ">"<br> writetabs(Spaces)<br> HTMLStr = HTMLStr & vbcrlf & "<input type=""" & TheObj(Value, j) & """ name=""" & theObj(HID,j) & "_ind_grp"" value=""" & IOC(0,iloop) & """>"<br> HTMLStr = HTMLStr & IOC(1,iloop) & vbcrlf & "</TD></TR>" & vbcrlf & vbcrlf<br> Count = Count + 1<br> next <br> end select </font><br> end if<br> Spaces = Spaces + 1<br> showtreeat theObj, theObj(HID, j), theObj(LID, j)<br> Spaces = Spaces - 1<br> end if<br>next<br>end sub<br></font></font><br><i> you'll notice at the top I have 3 nested if thens, may be more coding by from my perspective, if Change isnt true, it doesnt test the other two. the red is the part increased in speed by the loading of arrays above</i><br>and this the helper functions, and the main routine<br><FONT FACE=monospace> <font color=blue><br>'<!-- Help Functions --><br>'-- Does language lookup on all the Labels --<br>sub replacelang(byref LangObj, byref AryObj)<br> for w = LBound(AryObj,2) to UBound(AryObj, 2)<br> for x = LBound(LangObj,2) to UBound(LangObj, 2)<br> if AryObj(Label, w) = Cstr(LangObj(LangID, x)) then<br> AryObj(Label, w) = LangLookup(LangObj(LangTab,x), LangObj(LangRadio,x), LangObj(LangType,x))<br> end if<br> next<br> next<br>end sub<br><br>'-- Simulates the Tree-Look by throwing in 5 Spaces as tab for each level<br>sub writetabs(number)<br> for k = 0 to number<br> HTMLStr = HTMLStr & " "<br> next<br>end sub<br><br>'<!-- Main program begines --><br><br>replacelang LangData, AryData<br>showtreeat AryData, 0,0<br><br>set AryData = nothing<br>set LangData = nothing<br>Set ESA = nothing<br>Set RM = nothing<br>Set Occ = nothing<br>set IOC = nothing<br><br>Response.write "<form action=""FormatMulti.asp"" method=""Post"">" & vbcrlf<br>Response.Write vbtab & "<Table border=0 align=center Width=""90%"">" & vbcrlf<br>Response.Write vbtab & vbtab & "<TR><TD " & gTopColor & " align=center valign=middle colspan=2> <H1> " & LangLookup("Multi", "Report", "Print" & " </H1> </TD></TR>" & vbcrlf<br>Response.Write vbtab & vbtab & "<TR>" & vbcrlf<br>Response.Write vbtab & vbtab & vbtab & "<TD " & gTableCellColor & " width=""50%"" valign=top><Table border=0 width=""100%"">" & vbcrlf & HTMLStr1 & vbcrlf & "</Table></TD>" & vbcrlf<br>Response.Write vbtab & vbtab & vbtab & "<TD " & gTableCellColor & " width=""50%"" valign=top><Table border=0 width=""100%"">" & vbcrlf & HTMLStr & vbcrlf & "</Table></TD>" & vbcrlf<br>Response.Write vbtab & vbtab & "</TR>" & vbcrlf<br>Response.Write vbtab & vbtab & "<TR><TD " & gBottomColor & " align=center valign=middle colspan=2><input type=""Submit""></TD></TR>" & vbcrlf<br>Response.Write vbtab & "</Table>" & vbcrlf<br>Response.Write "</form>" & vbcrlf<br><br>Response.write "</body>" & vbcrlf & "</html>"<br>Response.Write Time() & vbcrlf<br><br>Response.Flush<br>%><br></font></font><br><br>My question to you all, is if you can recomend other ways of speeding this up, or sugestions?<br> <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>