Asp program-Defined variables are twice faster than non-Defined variables

Source: Internet
Author: User

Therefore, asp is the least restrictive among the many languages that I have come into contact with, and it is the one with the lowest requirements on programmers.

Yesterday I tested asp.net, php, and asp Running Speed comparison. Today I am impulsive. I want to see how much the effects of defining variables and non-defining variables on asp running efficiency are. The results are surprising, asp program-Defined variables are twice faster than non-Defined variables!

The test program was run for 10 million times yesterday to obtain the execution time.

1. The program does not define variables (dim I) Copy codeThe Code is as follows: <%
Dim startime
Startime = timer ()
For 1 to 10000000
Next
Dim endtime
Endtime = timer ()
Response. Write "Page execution time:" & FormatNumber (endtime-startime) *) & "millisecond"
%>

2. The program defines the variable (dim I)

Copy codeThe Code is as follows: <%
Dim I
Dim startime
Startime = timer ()
For 1 to 10000000
Next
Dim endtime
Endtime = timer ()
Response. Write "Page execution time:" & FormatNumber (endtime-startime) *) & "millisecond"
%>

Each program is executed five times (except for the first execution), and then the average value is obtained. The test results are as follows:

Define Variables Execution time Average time
No 1890 ms 1859 ms 1844 ms 1875 ms 1859 ms 1865 ms
Yes 890 ms 890 ms 984 ms 875 ms 890 ms 905 ms

According to the above test results, the execution speed of asp is twice faster than that of non-Defined variables.

As for why, I have not studied it further. However, through this example, I really feel that standardized programming can make the program run more efficiently. For non-standard programming, although the language itself is fault tolerant, the analysis process is time-consuming. Of course, for a simple program, there may be little difference between the norm and the non-norm, but if the system you develop is large, there are many pages, and there are many function calls, the difference between the time consumed by the specifications and non-standards will be highlighted, namely, 1 or 2 times less, and dozens of times more are not surprising.

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.