Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Increasing Efficiency(Speed)

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
US
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>&lt;% @Language=VBScript&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%&gt;<br>&lt;% <br>Response.Buffer = True <br>Response.Write Time() & vbcrlf<br>%&gt;<br>&lt;!--&lt;#include file=&quot;..\functions3.inc&quot;&gt;--&gt;<br>&lt;!--&lt;#include file=&quot;..\constants.inc&quot;&gt;--&gt;<br>&lt;%<br>Response.Write &quot;&lt;html&gt;&quot; & vbcrlf & &quot;&lt;head&gt;&lt;/head&gt;&quot; & vbcrlf & &quot;&lt;body &quot; & gLBgcolor & &quot;&gt;&quot;<br>'&lt;!-- Constants, globals, declarations --&gt;<br>Const HID&nbsp;&nbsp;&nbsp;= 0<br>Const LID&nbsp;&nbsp;&nbsp;= 1<br>Const Name&nbsp;&nbsp;= 2<br>Const RType = 3<br>Const Value = 4<br>Const Label = 5<br>Const HP&nbsp;&nbsp;&nbsp;&nbsp;= 6<br>Const LP&nbsp;&nbsp;&nbsp;&nbsp;= 7<br><br>Const LangID&nbsp;&nbsp;&nbsp;&nbsp;= 0<br>Const LangTab&nbsp;&nbsp;&nbsp;= 1<br>Const LangRadio = 2<br>Const LangType&nbsp;&nbsp;= 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 = &quot;&quot;<br>HTMLStr1 = &quot;&quot;<br><br>Dim RS<br>Dim Conn<br>Dim LangData<br>Dim AryData<br><br>Set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)<br>Set RS = Server.CreateObject(&quot;ADODB.Recordset&quot;)<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 &quot;Tree&quot;, &quot;sa&quot;, &quot;&quot;<br>RS.Open &quot;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&quot;,Conn, 0,1<br>If not RS.EOF then<br> AryData = RS.GetRows<br> RS.Close<br>end if<br>RS.Open &quot;Select * from LanguageLabel&quot;,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>'&lt;!-- Rescursive Subroutine with starting point --&gt;<br>sub showtreeat(byref theObj, HpLoc, LpLoc)<br>&nbsp;Dim TreeRow<br>&nbsp;TreeRow = UBound(theObj, 2)<br>&nbsp;for j = 0 to TreeRow<br>&nbsp;&nbsp;If theObj(HP,j) = HpLoc and theObj(LP,j) = LpLoc then<br>&nbsp;&nbsp;&nbsp;if Change = true then <br>&nbsp;&nbsp;&nbsp;&nbsp;If Spaces = 0 then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If count &gt; 45 then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Change = False<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr1 = HTMLStr<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = &quot;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;if theObj(RType,j) &lt;&gt; &quot;DataGroup&quot; then<br>&nbsp;&nbsp;&nbsp;If Spaces = 0 then<br>&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;&lt;TR&gt;&lt;TD &quot; & gHeader2CellColor & &quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;&lt;TR&gt;&lt;TD &quot; & gTableCellColor & &quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;&nbsp;writetabs(Spaces)<br>&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & vbcrlf & &quot;&lt;input type=&quot;&quot;&quot; & TheObj(RType, j) & &quot;&quot;&quot; name=&quot;&quot;&quot; & TheObj(Name, j) & &quot;&quot;&quot; value=&quot;&quot;&quot; & TheObj(Value,j) & &quot;&quot;&quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & TheObj(Label, j) <br>&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;&lt;/TD&gt;&lt;/TR&gt;&quot; & vbcrlf & vbcrlf<br>&nbsp;&nbsp;&nbsp;Count = Count + 1<br>&nbsp;&nbsp;else<br><font color=red>&nbsp;&nbsp;&nbsp;select case theObj(Label,j)<br>&nbsp;&nbsp;&nbsp;&nbsp;case &quot;ESA&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for esloop = LBound(ESA,2) to UBound(ESA,2)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;&lt;TR&gt;&lt;TD &quot; & gTableCellColor & &quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writetabs(Spaces)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & vbcrlf & &quot;&lt;input type=&quot;&quot;&quot; & TheObj(Value, j) & &quot;&quot;&quot; name=&quot;&quot;&quot; & theObj(HID,j) & &quot;_code&quot;&quot; value=&quot;&quot;&quot; & Trim(ESA(1,esloop)) & &quot;~&quot; & Trim(ESA(2,esloop)) & &quot;&quot;&quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & ESA(3,esloop) & &quot;&lt;/TD&gt;&lt;/TR&gt;&quot; & vbcrlf & vbcrlf<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count = Count + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next<br>&nbsp;&nbsp;&nbsp;&nbsp;case &quot;RM&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for rmloop = LBound(RM,2) to UBound(RM,2)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;&lt;TR&gt;&lt;TD &quot; & gTableCellColor & &quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writetabs(Spaces)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & vbcrlf & &quot;&lt;input type=&quot;&quot;&quot; & TheObj(Value, j) & &quot;&quot;&quot; name=&quot;&quot;&quot; & theObj(HID,j) & &quot;_code&quot;&quot; value=&quot;&quot;&quot; & Trim(RM(1,rmloop)) & &quot;~&quot; & Trim(RM(2,rmloop)) & &quot;&quot;&quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & RM(3,rmloop) & &quot;&lt;/TD&gt;&lt;/TR&gt;&quot; & vbcrlf & vbcrlf<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count = Count + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;next<br>&nbsp;&nbsp;&nbsp;case &quot;O&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;for oloop = LBound(Occ,2) to UBound(Occ,2)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;&lt;TR&gt;&lt;TD &quot; & gTableCellColor & &quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writetabs(Spaces)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & vbcrlf & &quot;&lt;input type=&quot;&quot;&quot; & TheObj(Value, j) & &quot;&quot;&quot; name=&quot;&quot;&quot; & theObj(HID,j) & &quot;_code&quot;&quot; value=&quot;&quot;&quot; & Occ(0,oloop) & &quot;&quot;&quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & Occ(1,oloop) & vbcrlf & &quot;&lt;/TD&gt;&lt;/TR&gt;&quot; & vbcrlf & vbcrlf<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count = Count + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;next<br>&nbsp;&nbsp;&nbsp;case &quot;IOC&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;for iloop = LBound(IOC,2) to UBound(IOC,2)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;&lt;TR&gt;&lt;TD &quot; & gTableCellColor & &quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writetabs(Spaces)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & vbcrlf & &quot;&lt;input type=&quot;&quot;&quot; & TheObj(Value, j) & &quot;&quot;&quot; name=&quot;&quot;&quot; & theObj(HID,j) & &quot;_ind_grp&quot;&quot; value=&quot;&quot;&quot; & IOC(0,iloop) & &quot;&quot;&quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & IOC(1,iloop) & vbcrlf & &quot;&lt;/TD&gt;&lt;/TR&gt;&quot; & vbcrlf & vbcrlf<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count = Count + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;next <br>&nbsp;&nbsp;&nbsp;end select </font><br>&nbsp;&nbsp;end if<br>&nbsp;Spaces = Spaces + 1<br>&nbsp;showtreeat theObj, theObj(HID, j), theObj(LID, j)<br>&nbsp;Spaces = Spaces - 1<br>&nbsp;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>'&lt;!-- Help Functions --&gt;<br>'-- Does language lookup on all the Labels --<br>sub replacelang(byref LangObj, byref AryObj)<br>&nbsp;for w = LBound(AryObj,2) to UBound(AryObj, 2)<br>&nbsp;&nbsp;for x = LBound(LangObj,2) to UBound(LangObj, 2)<br>&nbsp;&nbsp;&nbsp;if AryObj(Label, w) = Cstr(LangObj(LangID, x)) then<br>&nbsp;&nbsp;&nbsp;&nbsp;AryObj(Label, w) = LangLookup(LangObj(LangTab,x), LangObj(LangRadio,x), LangObj(LangType,x))<br>&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;next<br>&nbsp;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>&nbsp;for k = 0 to number<br>&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;     &quot;<br>&nbsp;next<br>end sub<br><br>'&lt;!-- Main program begines --&gt;<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 &quot;&lt;form action=&quot;&quot;FormatMulti.asp&quot;&quot; method=&quot;&quot;Post&quot;&quot;&gt;&quot; & vbcrlf<br>Response.Write vbtab & &quot;&lt;Table border=0 align=center Width=&quot;&quot;90%&quot;&quot;&gt;&quot; & vbcrlf<br>Response.Write vbtab & vbtab & &quot;&lt;TR&gt;&lt;TD &quot; & gTopColor & &quot; align=center valign=middle colspan=2&gt; &lt;H1&gt; &quot; & LangLookup(&quot;Multi&quot;, &quot;Report&quot;, &quot;Print&quot;) & &quot; &lt;/H1&gt; &lt;/TD&gt;&lt;/TR&gt;&quot; & vbcrlf<br>Response.Write vbtab & vbtab & &quot;&lt;TR&gt;&quot; & vbcrlf<br>Response.Write vbtab & vbtab & vbtab & &quot;&lt;TD &quot; & gTableCellColor & &quot; width=&quot;&quot;50%&quot;&quot; valign=top&gt;&lt;Table border=0 width=&quot;&quot;100%&quot;&quot;&gt;&quot; & vbcrlf & HTMLStr1 & vbcrlf & &quot;&lt;/Table&gt;&lt;/TD&gt;&quot; & vbcrlf<br>Response.Write vbtab & vbtab & vbtab & &quot;&lt;TD &quot; & gTableCellColor & &quot; width=&quot;&quot;50%&quot;&quot; valign=top&gt;&lt;Table border=0 width=&quot;&quot;100%&quot;&quot;&gt;&quot; & vbcrlf & HTMLStr&nbsp;&nbsp;& vbcrlf & &quot;&lt;/Table&gt;&lt;/TD&gt;&quot; & vbcrlf<br>Response.Write vbtab & vbtab & &quot;&lt;/TR&gt;&quot; & vbcrlf<br>Response.Write vbtab & vbtab & &quot;&lt;TR&gt;&lt;TD &quot; & gBottomColor & &quot; align=center valign=middle colspan=2&gt;&lt;input type=&quot;&quot;Submit&quot;&quot;&gt;&lt;/TD&gt;&lt;/TR&gt;&quot; & vbcrlf<br>Response.Write vbtab & &quot;&lt;/Table&gt;&quot; & vbcrlf<br>Response.Write &quot;&lt;/form&gt;&quot; & vbcrlf<br><br>Response.write &quot;&lt;/body&gt;&quot; & vbcrlf & &quot;&lt;/html&gt;&quot;<br>Response.Write Time() & vbcrlf<br><br>Response.Flush<br>%&gt;<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>
 
Why you already saved 50%<br>What's a couple of seconds in a life span.<br><br>And how much time did YOU spend making it quicker.<br><br>Bunches of people are moving to broad band every day. <br>And then it won't matter cause 13-20 seconds becomes 1.5 seconds.<br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
&gt; Bunches of people are moving to broad band every day. <br>&gt; And then it won't matter cause 13-20 seconds becomes 1.5 seconds.<br><br>Wow, did you ever miss the point on that one! Whew! Earth to Doug... anybody home? ;o)<br><br>-pete
 
did I mention that timming is based off my LAN network, anyways it needs to be as fast as I Can get it, the customers dont want to wait around for just the start screen(where all the selections are made) they can wait while their request is being processed, in any case, the faster I can get it, the better I can add more to it, and the Timming is done based on how long it takes the page to process then send back, not how long it takes to download it. to download that small HTML would be nearly a split second, but to actually execute some of the stuff on there takes a bit longer, so I really think you misunderstood me. <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>
 
Karl:<br><br>You did&nbsp;&nbsp;a good job. But are you considering the server load too? You are opening quite good number of recordset and taking server resources too. If too many customers are working concurrent then server may face resource problem too. you have to think of locking mechanism also carefully, if more nos. of records are open at given time for each session.<br><br>It is always better to get good/optimised response time. it also depend upon objective/priorties of application also. <br><br>Well done.<br><br>Anand
 
Actually I'm <b>Only</b> considering the serverside processing, because I know clientside download will vary, running it right off a 10Mbit lan, I can see the smallest speed possible, which in this case varies 3-7 second, which is almost the exact serverside, I have the Time() spit out at the top, then at the bottom, then have the Page flushed to the client, so the Times are the beginning and end, before it's sent to the client, so I'm judging only on serverside processings. <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>
 
Karl -<br><br>I agree that you need faster response times.&nbsp;&nbsp;Rule of thumb in internet delivery is that if the page doesn't appear in 8 seconds, the user will hit the &quot;back&quot; button.&nbsp;&nbsp;And that applies even if the user has a 14,400 modem!<br><br>What I might suggest is that you remove parts of your code until you isolate which section is consuming all the time.&nbsp;&nbsp;Right now (without running any tests), the ReplaceLang function looks suspicious, since you've got a call to LangLookup() inside a double-nested loop.<br><br>Chip H.<br>
 
LangLookup is a nessasity, it send 3 parameters, and returns the label that is in the proper language(english, spanish, so on) its in an ActiveX control, the ReplaceLang, goes through the array, and finds every label that matches a number in the language table(which contains the 3 paramters to pass to the control to get back the proper label) right now, just running throught the array replacing them as I find them is the only way I know how. <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>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top