What is the best choice for improveing ​​ASP performance (1)

zhaozj2021-02-08  263

(Author: Green Apple studio compilation of November 10, 2000 Ri 17:20) ASP developers for better performance in their design projects and scalability and continuous efforts. Fortunately, there are many books and sites that provide good advice in this regard. However, these recommendations are the conclusions obtained from the structure of the ASP platform, and there is no measurement for the improvement of the actual performance. Since these recommendations require more complex coding processes and reduce encoding readability, developers can only measure whether their ASP applications can be paid in order to improve their ASP applications without causing actual operation. This article is divided into two parts, I will introduce some performance test results to help developers to determine if a particular initiative is worthy of the future project, but can be updated for the original project. In the first part I will review some basic issues developed by ASP. In the second part, some Optimization ADO functions will be involved, and their results are compared to the ASP page that calls VB COM objects. These results are very eye-catching, even sometimes surprising. In this article, we will answer the following questions: * What is the most effective way to write the contents of the ASP in response stream? * Is the buffer should be turned on? * Do you should consider adding comments to the ASP code? * Is the default language should be explicitly set for the page? * If you don't need it, should you close the Sems status? * Whether the script logic should be placed in a subroutine and a function area? * What is the impact of using the included file? * What load is applied when performing error processing? * Set whether a context process has an impact on performance? All tests are done with Microsoft's Web Application Key Tools (WAST), this is a free tool, which can be found here. I created a simple Test script with WAST, repeatedly calls the ASP page test described below (more than 70,000 times). The reaction time is based on the average last byte total time (TTLB), that is, the time to receive the last bit data from the server from the server. Our test server is a Pentium 166, which is 196MB, and the client is Pentium 450, and memory is 256MB. You may think that the performance of these machines is not very advanced, but don't forget, we are not to test the capacity of the server, we just want to test the time used by the server each time you process. These machines do not do other jobs during the test. WAST test script, test report, and all ASP test pages are included

ZIP file

In you can review and test themselves. What is the most effective way to write the content of the ASP in response? One of the most important reasons used to use ASP is to generate dynamic content on the server. Therefore, it is clear that the starting point of our test is to determine the most suitable way to send dynamic content to the response stream. In a variety of options, there are two most basic: First, use the inline ASP tag, the other is to use the response.write statement. To test these options, we created a simple ASP page that defines some variables and then inserts their values ​​into the table. Although this page is simple or practical, it allows us to separate and test some separate questions. Using ASP Inline Tags The first test includes using an inline ASP tag <% = x%>, where x is an assigned variable. So far, this method is the easiest to perform, and it keeps the page's HTML section a format that is easy to read and maintain.

<% OPTION EXPLICIT Dim FirstName Dim LastName Dim MiddleInitial Dim Address Dim City Dim State Dim PhoneNumber Dim FaxNumber Dim EMail Dim BirthDate FirstName = "John" MiddleInitial = "Q" LastName = "Public" Address = "100 Main Street" City = "New York "state =" NY "phonenumber =" 1-212-555-1234 "faxNumber =" 1-212-555-1234 "Email =" john@public.com "birthdate =" 1/1/1950 "%> < HTML> Response test </ title> </ head> <body> <h1> response test </ h1> <table> <tr> <td> <b> first name: </ b> < / TD> <TD> <% = firstname%> </ td> <b> Middle Initial: </ b> </ td> <td> <% = middleinitial%> < / TD> </ tr> <tr> <td> <b> Last Name: </ b> </ td> <td> <% = lastname%> </ td> </ tr> <tr> <td> <b> address: </ b> </ td> <td> <% = address%> <TD> </ Tr> <Tr> <TD> <b> city: </ b> </ td> < TD> <% = city%> </ td> </ tr> <tr> <td> <b> state: </ b> </ td> <td> <% = state %> </ td> <b> phone number: </ b> </ td> <td> <% = phonenumber%> </ td> </ tr> <TR> <TD> <b> fax number: <TD> <B> Fax Number: <</p> <p>/ b> </ td> <td> <% = faxNumber%> </ td> <b> Email: </ b> </ td> <td> <% = email %> </ td> <b> Birth Date: </ b> </ td> <td> <% = birthdate%> </ td> </ tr> </ table > </ Body> </ html> /App1/response1.asp The full code for the full code for previous codes (Reaction speed) = 8.28 MSEC / Page In each line of HTML, using the response.write statement Many better learning documents suggests to avoid use The method of the front. Its main reason is that during the output page and the processing page to apply a reaction time, if the web server has to transform between sending pure HTML and processing scripts, there is a problem that is called context transformation. Most of the programmers heard here, their first reaction is to package the original HTML every line in the response.write function. ... response.write ("<html>") response.write ("<head>") response.write ("<title>") Response.write ("</ head>") response. Write ("<body>") Response.write ("<h1>") response.write ("<Table>") response.write ("<tr> <TD> <b> first name : </ b> </ td> <td> "& number") response.write ("<tr> <td> <b> Middle Initial: </ b> </ TD> <TD> "& MiddleInitial &" </ TD> </ TR> ") ... /App1/Response2.asp The best (reaction speed) = 8.28 msec / Page reaction time = 8.08 msec / Page difference = -0.20 msec (decrease 2.4%) We can see that using this method is very small in performance with the method of using the inline mark, this may be because the page is loaded with a small pin to the server. Function call. The biggest disadvantage of this method is that since the HTML is now embedded in the script, the script code becomes more lengthy, more difficult to read and maintain.</p> <p>Using a packaging function When we try to use the response.write statement, the most discouraged discovery may be that the response.write function cannot be placed at the end of each row at the end of each row. Therefore, when you read the source code from your browser, it is very good HTML, and now there is no end. I think your next discovery may make you a horrible: there is no sister function writern in the response object. So, a significant reaction is to create a packaging function for the Response.Write function to add a CRLF to each line. ... WriteCr ("<tr> <TD> <B> First Name: </ b> </ td> <TD>" & firstname & "</ td> </ tr>") ... Sub WriteCr (STR) response. Write (STR & VBCRLF) End Sub /App1/Response4.asp's fragment previously optimal (reaction speed) = 8.08 msec / PAGE reaction time = 10.11 msec / Page difference = 2.03 msec (increasing 25.1%) Of course, due to this The method effectively doubles the number of function calls, and its impact on performance is also obvious, so we must avoid all costs. Ironically, CRLF also adds two bytes to the reaction stream, which is that the browser does not need to be rendered on the page. Everything to format good HTML is to make your competitors easier to read your HTML source code and understand your design. Connect a continuous response.write in a separate statement, not considering the test of our front packaging function, the next logical step is to extract all strings from a separate response.write statement, connect them to one In separate statements, this reduces the number of functions calls, greatly improves the performance of the page.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-1388.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="1388" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.059</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'O98OJ7hKI4Lpfu7NlwPkiJMAk5A9CenAvlx9jgtdn2ubwww7WxWMszZ5vLYLR0si2uCaiSJiLc5wpR_2ButD2Rrg_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>