Results 1 to 22 of 22

Thread: ASP Speed Tweaking

  1. #1

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Is there any advantage to doing the bulk of the processing before the <html> tag, and just using <%= %> a couple of times. How about if I would edit the unused constants out of my ADOVBS.INC file?

    Any other tips?

    Thanks,
    Josh

  2. #2
    Addicted Member
    Join Date
    Feb 2000
    Posts
    224
    U are right...

    If the Processing is done Separately...There is no need for the Processor to Jump from scripting mode to html mode to and fro...

    'I don't use Adovbs.inc... I just copy those required constants in my asp page.
    If you can't pronounce my name, call me GURU

  3. #3
    Guest
    MSDN has some great articles on this topic.

    http://msdn.microsoft.com/workshop/s...sp/maxperf.asp

    http://msdn.microsoft.com/workshop/s...er03272000.asp

    My best suggestion is do processing in COM components, they are faster by a factor of hundreds because they're already compiled.

  4. #4
    Guest
    Hangon...what's this about the server switching from html to asp mode?

    It's my understanding that when an ASP page is requested, the server farms the request out to the ASP engine which processes ALL the vbscript there and then. It ignores all html markup. Once it has replaced everything within <% %> tags with the code's results it sends the page back to the server which passes in on to the browser as the reply to the original request. NOTHING ON THE SERVER EVER PROCESSES ANY HTML. Only the browser actually processes the html.

    Assuming what I have said above is correct then I see no advantage to putting all your vbscript before your html, other than making easier to understand.

    As for the adovbs.inc file then only using the constants you actually use will marginally improve performance - less for the asp engine to process but I can't imagine there is much speed to be gained. Other factors like inefficient coding and the time taken to connect to other servers will have a much bigger impact on the speed of your pages.

  5. #5

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Thanks,

    I was thinking about going to COM, but since it's an Intranet server, traffic's not that high and COM DLLs will be a heck of a lot harder for someone else to maintain later.

    As far as switching between HTML and ASP, I thought that the server has to parse the script for #includes before sending it to the ASP engine, or does the ASP engine handle that as well?

    And since you can do things like
    Code:
    <% If str = "Good" then %>
    <p>Good
    <% Else %>
    <p>Bad
    <% End If %>
    The ASP engine seems to do a little more with the HTML than just replace <% %> tags.


    Josh

  6. #6
    Guest
    Sorry...I simplified it a little to much...in my explanation before the asp engine would treat
    Code:
    <% if ... then %>
    <h1>...</h1>
    <% else %>
    <h2>...</h2>
    <% end if %>
    as one asp block to be replaced by either "<h1>...</h1>" or "<h2>...</h2>" depending on the result of the if statement. The html itself isn't processed on the server machine...the most that happens to it is that some (like you have mentioned) might be cut out before the browser receives the page.

    And yes the web server does process all SSI statements before it gives the page to the asp engine, however SSI statements are not HTML so what I said before is correct.

  7. #7
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    Actually every time you switch between ASP tags (<% %>) and HTML tags, something called context switching occurs. This is inefficient. Block together as much ASP code as possible in order to avoid context switching.

    From what I understand, your web server must switch between the ASP.DLL thread and INETINFO thread (or something like that) when it changes the tag type


    AWESOME, MUST-READ article on ASP performance here
    http://www.asptoday.com/articles/20000113.htm

  8. #8
    Guest
    That's daft that. Tell Microsoft to get their act together an do it properly. The server doesn't need to process the html so why pass it back to the web server every time it spots html tags...oly to be passed back again when asp code is found?

  9. #9
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    Don't quote me on that Matthew, I was only speculating on what happens. I do know for certain though that context switching occurs, so that was my logical guess. Ya think?

  10. #10
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    Maybe it's between the script engine and ASP.....yeah, that makes more sense......

  11. #11
    Guest
    Mmm...it does seem silly, pointless and inefficient.
    I can't see that Microsoft (aside from all their shortcomings) would be that stupid.

    Aside from perhaps not devoting enough time to debugging, Microsoft's software is usually pretty good - bugs aside it's normally extremely functional, easy to use, looks professional and is pretty quick and efficient.

    I find it very hard to belive that they would make such an inefficient a product to be used by so many programmers who could just as easily use php or perl or cold fusion or... or... or...

  12. #12

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    That's what I was wondering about in the first place. I suppose I'll put all the ASP together just because it looks better that way. Now, if I would put VBScript, JScript, and PerlScript all on the same page, and mix in lots of <% %> and <object runat=server> tags, I wonder what would happen...

    Josh

  13. #13
    Guest
    You'd be declared criminally insane and carted off to the funny farm.

    Also how do you expect to get the server to send the page to all three engines (without writing your own isapi or cgi filter that farms it out that is)?

  14. #14
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    I want to add something to this thread. If you want your ASP code to be as fast as possible, then you shouldn't mix HTML with ASP Script. According to Microsoft if you use pure ASP, it would be a lot faster (around 2.5 - 3 times faster) then mixing it with HTML. Here is an example:

    This would be slower:
    Code:
    <Select name lstMyList size=10>
        <%Do Unil rs.EOF%>
            <option><%=rs("MyValue")%></option>
            <%rs.MoveNext%>
       <%Loop%>
    </Select>
    then this:
    Code:
    <%
    Response.Write "<Select name lstMyList size=10>"
    Do Until rs.EOF
        Response.Write "<option>" & rs("MyValue") & "</option>"
        rs.MoveNext
    Loop
    Response.Write "</Select>"
    %>
    Just my $0.02

  15. #15
    Guest
    Quite possibly true but it's harder to read (IMHO of course).

    Also I think that in the majority of cases it wouldn't make all that much difference. Inefficient coding will have a bigger impact on the speed of the page.

  16. #16
    Addicted Member
    Join Date
    Feb 2000
    Posts
    224
    Mathew...

    You can Change Language by using Script tags

    <SCRIPT LANGUAGE="VBScript" RUNAT="Server">

    </SCRIPT>

    <SCRIPT LANGUAGE="JScript" RUNAT="Server">

    </SCRIPT>

    on the same page...

    But i never tried it... and I won't...
    If you can't pronounce my name, call me GURU

  17. #17
    Guest

    Red face

    {LOOKING MILDLY IMPRESSED THEN VERY QUICKLY BORED}

    Mmmm...fair 'nuff.

  18. #18

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Serge, I would end up doing something like:

    Code:
    <%
    Dim out
    
    out = out & "<Select name lstMyList size=10>"
    Do Until rs.EOF
        out = out & "<option>" & rs("MyValue") & "</option>"
        rs.MoveNext
    Loop
    out = out & "</Select>"
    %>
    <%= out %>
    Any benefits?

    Thanks,
    Josh

  19. #19
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    The benefit is Easier to read and probably would be a bit faster since you're writing it only once.


  20. #20
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    In case you guys still care:

    Serge's method is faster as the Response.Write just adds the string to the end of the output buffer. When you append strings to strings in VB/VBScript the operation is comparatively slow

    Benchmarks here on that and other great stuff
    http://www.asptoday.com/articles/20000426.htm

  21. #21
    Guest
    Everybody prepare to be amazed, look at this, no loop required!

    Try the ADO getstring method.

    after retrieving recordset do this
    Code:
    str = "<option value =" & rs.getstring(,,">","</option><option value=")
    then in the html
    Code:
    <select name="select">
    <%=str%>
    </select>

  22. #22
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    I like it! You can do the same thing with </TD><TD> tags as well to create a basic table

    To further optimize your page time, remove the </option> from the string -- browsers today don't require this tag and you can save yourself 9 bytes per item


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width