ASP program definition variable faster than not defined variable speed _ Application Tips

Source: Internet
Author: User
Therefore, in my exposure to so many languages, ASP is the least stringent one, is the least required for programmers.

Yesterday tested the ASP.net, PHP and ASP running speed comparison, today again to impulse, want to see the definition of variables and undefined variables on the efficiency of ASP, the effect of how much, the result is surprising, the ASP program to define variables faster than the definition of variable speed one times!

Test program or yesterday, run 10 million for loop, get execution time.

1, the program does not define variables (Dim i)
Copy Code code as follows:

<%
Dim startime
Startime=timer ()
For i = 1 to 10000000
Next
Dim endtime
Endtime=timer ()
Response. Write "Page Execution Time:" & FormatNumber ((endtime-startime) *1000,3) & "milliseconds"
%>


2, the program defines the variable (Dim i)

Copy Code code as follows:

<%
Dim i
Dim startime
Startime=timer ()
For i = 1 to 10000000
Next
Dim endtime
Endtime=timer ()
Response. Write "Page Execution Time:" & FormatNumber ((endtime-startime) *1000,3) & "milliseconds"
%>


The program executes 5 times (except for the first execution), and then averages the values. The test results are as follows:

Defining variables Execution time Average Time
Whether 1890ms 1859ms 1844ms 1875ms 1859ms 1865ms
Is 890ms 890ms 984ms 875ms 890ms 905ms

From the above test results, the definition of variables than the definition of variables, ASP's execution speed is one times faster.

As for why this is the case, I have not further in-depth study. But through this example, I do feel that spec programming makes the program run more efficiently. For nonstandard programming, the language itself is fault tolerant, but its analysis process takes time. Of course, for a simple program, perhaps the difference between the specification and the time it takes to not standardize is negligible, but if you develop a larger system, more pages, more function calls, then the specification and nonstandard their time difference will be highlighted, less 1, twice times, more than dozens of times times are not odd.

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.