ASP网页设计asp内存和速度优化,第一局部(英文版)...
ASP一般认为只能运行在IIS上,正如前面所提到的,这并不是十分正确,事实上,ASP也能运行在Apache上。Apache ASP可在任意Apache服务器上运行有限的ASP功能,所需做的,只需打开mod_perl。速度|优化 Memory and Speed Optimization with ASP - Part IIt is an all to familiar problem: optimizing the memory and speed of your web sites. Maybe you have been, more than once a week, in the situation where your web server stopped giving you any ASP page, while the HTML pages were correctly displayed. One of the challenges faced by the web developers is how to create a fast (usually a faster that the one you have) application out of a series of HTML and ASP pages.
When programming ASP pages, memory and speed optimization can be acquired in two different ways. Because HTML pages are not processed at the server-side, we will talk more about memory and speed optimization of ASP pages:
By programming good ASP pages. This article is all about optimizing by writing good ASP pages.
By configuring the web server. We will cover this topic in another article.
When talking about optimizing ASP pages, we should start from the deepest level: basic variables.
One of the biggest differences between Visual Basic (VB) and ASP programming is the variable declaration. VB is a programming language, so you can define variables of a specific type:
Dim I as Integer ' Integer Declaration
Dim a$ ' String declaration
Dim objMyCom as Object ' Object Declaration
Dim var as Variant ' Variant declaration
While ASP is a scripting language, where the only available type is VARIANT type. All the variables declared in ASP are of type VARIANT . Unfortunately, this makes all the operations slower, because the work with VARIANT is slower. The system has to first evaluate the type of the variant, convert it to the most appropriate of the operation that is to be done, and then make the operation.
VARIANT is a very smart type of variable. It has great capabilities of storing EMPTY and NULL values, along with any types of data, such as (integers, doubles, strings, currency and dates, arrays or objects).
Optimizing memory and speed when working with ARRAYS.
ASP programmers are usually not very good friends with ARRAYS. Using ARRAYS is more common to VB programmers that use them to store data. As little as you use arrays, you should have in mind the following way of optimizing array access:
Arrays are made from continuous blocks of memory. Reading and writing an item of an array is slower than accessing a simple variable. For each access to an item in an array, the runtime environment has to determine the position of the item in the memory, based on the first element of the array and the index. Therefore, it's faster to read/write a variable, than an array item. Therefore, if you need to use the same array item in a loop repeatedly, you'd better assign the item to a variable and use that variable instead.
E.g. :
<%
' this will calculate for each element, the value a(i) = 2i ( = 2 * 2 * 2 - for i times)
Dim a(20) ' The array
Dim i,j ' indexes
Dim tempVar ' a temporary variable
' Non-optimized Array Access:
For i = lBound(a) to uBound(a)
a(i) = 1
For j = 2 to i
a(i) = a(i) * 2
next j
Next
' Optimized Array Access
For i = lBound(a) to uBound(a)
tempVar = 1
For j = 2 to i
tempVar = tempVar * 2
next j
a(i) = tempVar
Next
%>
Because of the way of calculating the position of an element in memory, access to items in bidimensional arrays is very slow when compared to accessing items in single dimensional arrays. Think about this when designing your algorithms.
A good way of optimizing speed of multidimensional arrays is to reduce them to a single dimensional array. Instead of using a 10 by 10 matrix, try to use a 100-element array to speed up access. In this case, you have to manually find your items in the array. If you use i and j as indices, and you used to access an element like A(i, j), the new way of accessing the items will be A((i*10)+ j), where i and j are the original indices.
In ASP there are few ways of declaring arrays. The difference between the declaration method is the way in which ASP allocates and uses memory.
1. Dim A (10) ' declaration of static array with 10 elements
Access to its i</p>ASP在国内异常流行,因为国内大多使用的是盗版的Windows和盗版的SQLServer,而ASP+COM+SQLServer实际上也是一种不错的搭配,其性能也不输于PHP+MYSQL,特别是Windows系统和SQLServer都有图形界面,比APACHE和MYSQL易于维护,因此对于不重视知识产权的国家来说也是一种不错的选择。 运用经典的例子。并且自己可以用他来实现一些简单的系统。如果可以对他进行进一步的修改,找出你觉得可以提高性能的地方,加上自己的设计,那就更上一个层次了,也就会真正地感到有所收获。 如何更好的使自己的东西看上去很不错等等。其实这些都不是问题的实质,我们可以在实践中不断提升自己,不断充实自己。 他的语法和设计思路和VB完全相同,导致很多ASP的书都留一句“相关内容请参考VB的相关教材....”更糟糕的是,相当多的ASP教程混合了Javascript,VBscript等等脚本语言,搞的初学者。 那么,ASP.Net有哪些改进呢? 我想问如何掌握学习节奏(先学什么再学什么)最好详细点? 先学习用frontpage熟悉html编辑然后学习asp和vbscript建议买书进行系统学习 Application:这个存储服务端的数据,如果不清除,会直到web应用程序结束才清除(例如重启站点) 以上是语言本身的弱点,在功能方面ASP同样存在问题,第一是功能太弱,一些底层操作只能通过组件来完成,在这点上是远远比不上PHP/JSP,其次就是缺乏完善的纠错/调试功能,这点上ASP/PHP/JSP差不多。 我们必须明确一个大方向,不要只是停留在因为学而去学,我们应有方向应有目标. 学习ASP其实应该上升到如何学习程序设计这种境界,其实学习程序设计又是接受一种编程思想。比如ASP如何学习,你也许在以前的学习中碰到过。以下我仔细给你说几点: 我想问如何掌握学习节奏(先学什么再学什么)最好详细点? 我认为比较好的方法是找一些比较经典的例子,每个例子比较集中一种编程思想而设计的。 我可以结合自己的经验大致给你说一说,希望对你有所帮助,少走些弯路。 Application:这个存储服务端的数据,如果不清除,会直到web应用程序结束才清除(例如重启站点) ASP(ActiveServerPages)是Microsfot公司1996年11月推出的WEB应用程序开发技术,它既不是一种程序语言,也不是一种开发工具,而是一种技术框架,不须使用微软的产品就能编写它的代码,能产生和执行动态、交互式、高效率的站占服务器的应用程序。 不是很难但是英文要有一点基础网上的教程很少有系统的详细的去买书吧,另不用专门学习vb关于vbscript脚本在asp教材都有介绍 跟学别的语言一样,先掌握变量,流程控制语句(就是ifwhileselect)等,函数/过程,数组 接下来就不能纸上谈兵了,最好的方法其实是实践。实践,只能算是让你掌握语言特性用的。而提倡做实际的Project也不是太好,因为你还没有熟练的能力去综合各种技术,这样只能使你自己越来越迷糊。 我认为比较好的方法是找一些比较经典的例子,每个例子比较集中一种编程思想而设计的。
页:
[1]