Improving program performance is a delicate matter. Especially programs related to INTERNET, such as ASP programs, have many factors that restrict their performance, such as WEB servers, TCP/IP networks and database servers.
Most of these are related to hardware. In fact, in terms of software, good programming methods and correct parameter configuration can also improve the performance of the program. Sometimes, under the same circumstances, just changing one parameter can greatly improve the execution efficiency of the program. This article attempts to do some exploration in this regard.
1. Factors affecting performance
The performance of ASP program running is mainly determined by the following two major aspects:
1. Execution efficiency of HTML pages
2. Reaction time, in which reaction time is mainly controlled by the following factors:
(1).Execution efficiency of ASP pages
(2).Database factors
Let’s discuss it in detail below.
2. Detailed discussion
1. Factors affecting HTML
The execution efficiency of HTML pages is a purely client-side issue. The factors that affect this problem are mainly the client's hardware and its network bandwidth. In addition, there are some following factors that can also affect the execution efficiency of HTML pages.
(1).Image factors. Try to avoid using images in HTML pages. This is because when the browser requests a page, if the page contains N images, this will cause the browser to request N calls to the WEB server. This kind of request will slow down the page loading process. This in turn affects the speed.
(2).Framework issue. Using frames in web pages will also reduce the loading process of the page. Similar to image factors, loading an N frame also requires N requests.
(3). For table issues, try to avoid using tables, especially try to avoid using multiple tables. Complex tables will affect the execution efficiency of HTML.
(4). Remove redundant markers. Let us take a look at the following example:
Copy the code as follows:<Body><br>
<P><font face=Verdana size=4><br>
</font></P><br>
<P><font face=Verdana size=4>< br>
</font></P><br>
<P><font face=Verdana size=4><br>
</font></P><br>
</Body><br>
You can remove< font> tag, as follows:
<Body><br>
<font face=Verdana size=4><br> <P>
<br>
</P> <br>
<P> <br>
</P><br>
<P> <br>
</P><br>
<font> </Body><br>
(5). Reduce comments, which will reduce the file size. This improves loading speed.
(6). Avoid using long file names, and try to use relative paths to access other files in the page.
(7). Try to avoid using Java Applets in HTML pages. For example, if you want to use Java Applets to process animations, then you can consider using GIF files or FLASH instead, which will be much faster than Java Applets.
2. Factors affecting ASP
(1). Try to convert object variables into local variables, because reading local variables is much faster than reading object variables.
Slower example:
Copy the code as follows:
if Myobj.Value = 0 then
Do something
elseif Myobj.Value > 0 then
Do something
elseif Myobj.Value < 0 then
Do something
end if
Faster example:
Copy the code as follows:
MyVar = Myobj.Value
if MyVar = 0 then
Do something
elseif MyVar > 0 then
Do something
elseif MyVar < 0 then
Do something
end if
(2). If you are using VBScript 5.0 or a newer version, try to use the With ... End With statement, which can also improve the running speed of your program.
Slower example:
Copy the code as follows:
Myobj.FirstName = Srinivasa
Myobj.LastName = Sivakumar
Myobj.City = Chicago
Faster example:
Copy the code as follows:
With Myobj
.FirstName = Jinhu.LastName
= Ma.City
= Chuzhou
End with
(3). Generally speaking, avoiding the use of session variables can help improve speed. This is because different ASP pages run in different threads, but session calls are not like this. They are continuous.
3. Database issues:
Designing a database structure can greatly improve the running speed of the program. Of course, how to design the database structure is not the issue discussed in this article. Let's first assume that the database structure has been designed and see what else can be done to improve the running speed of the program.
(1). If your database server and WEB server are the same, it is best to separate them. This will definitely improve speed.
(2). If you access the database, it is best not to use dynamic SQL statements and use stored procedures or views.
(3). Sometimes allocating appropriate database buffers will improve program performance. This is because, if you are using an Oracle database, you need to open three sessions for each connection. If you can take care of these things, you will improve the performance of your program.
Summary
: In fact, there are many factors that affect the execution speed of ASP programs, and the above are just some of them. Of course, some of the above techniques may not be suitable for all ASP programs, and different strategies should be adopted for different programs. Finally, I hope the above article can be helpful to you.