ASP Performance test report (Turn) (eight)

Source: Internet
Author: User
Tags date benchmark
Performance use procedures and functions have great benefits for the organization and maintenance of code, especially when some of the code in the page needs to be used more than once. However, it is a disadvantage to have a function (or procedure) call to complete the same processing task at this point in time. Theoretically, the variables within the function block are more efficient. Let's take a look at the test results for these two questions.

8.1 Moving the Response.Write statement into the child procedure

In this test, we just put the Response.Write statement into the sub process.
...
Call Writetable ()

SUB writetable ()
Response.Write ("< HTML >" & _
"< head >" & _
...
"< TR >< TD >< B >EMail:</b ></td >< td >" & EMail & "</td ></tr > "& _
"< TR >< TD >< B >birth date:</></td >< td >" & Birthdate & "</td > </tr > "& _
"</table >" & _
"</body >" & _
"End SUB

/app2/function1.asp Fragment

Benchmark = 5.57 MS/page
Response time = 6.02 MS/page
difference = +0.45 milliseconds (increase by 8.1%)




As expected, child process calls add additional page handling burdens.

8.2 Moving all scripts into the child process

In this test, Response.Write and all the variable declarations are moved to the sub process.
<% OPTION EXPLICIT
Call Writetable ()

SUB writetable ()
Dim FirstName
...
Dim Birthdate
FirstName = "John"
...
Birthdate = "1/1/1950"
Response.Write ("< HTML >" & _
"< head >" & _
"< title >response test</title >" & _
""< BODY >" & _
"< H1 >response test

"< table >" & _
"< TR >< TD >< B >first name:</></td >< td >" & FirstName & "</td > </tr > "& _
...
"< TR >< TD >< B >birth date:</></td >< td >" & Birthdate & "</td > </tr > "& _
"</table >" & _
"</body >" & _
"End SUB

/app2/function2.asp Fragment

Benchmark = 5.57 MS/page
Response time = 5.22 MS/page
difference =-0.35 milliseconds (6.3% reduction)




Although there are still additional function calls, putting the variable declaration inside the function actually increases performance beyond the benchmark, which is a noteworthy result! We get the following rules:

If you want to use more than one part of the code in a page, encapsulate them with a function.
If appropriate, move the variable declaration to the function.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.