asp内存和速度优化,第一部分(英文版)

本文探讨了ASP网页中关于内存和速度的优化方法,重点介绍了通过编写高效ASP页面和合理配置Web服务器来提升网站性能的技术。针对变量声明、数组操作及对象使用等方面给出了具体建议。
导读:
  Memory and Speed Optimization with ASP - Part I
  It 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

%>  ' 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 items is the fastest, and uses less memory. Unfortunately, it can not be resized.
  2. Dim A ( ) ' declaration of dynamic array, with unspecified number of elements
  Redim A(10) ' Dimensioning the array to the requred size
  After the declaration, before its first usage, the array has to be dimensioned using Redim A(nr of items). By using this declaration, you avoid problems of dimensioning the array, but you slow down the access to the array's items by 50 -60%!
  3. Dim A ' declaration of a Variant variable
  Redim A(1000) ' assignment of an array to the variant
  Declaration of a variable, which has an array assigned to it. The access to its items is 50% slower than for case 2, and about 75-80% slower than the first declaration.
  4. Dim A ' declaration of a Variant variable
  A = Array( 1, 2.0 , "three" ) ' assignment of an array created, when we know their number and values
  This declaration mode seems to be as fast the first one, because of the function call "Array". Unfortunately this way of declaration is not very handy, because you have to have access to all the Array’s items from the declaration point.
  Another problem that appears when using arrays is of re-dimensioning the arrays by using:
  Redim a(200) ' re-dimensioning the array to another size
  Or by using:
  Redim Preserve a(200) ' re-dimensioning the array to another size, and
  ' preserving it's current values
  When re-dimensioning arrays, the runtime environment has to create a block of memory of the new required size, copy the old values of the array to the new array (if you are using Redim), and eventually cropping the array (if the new size is smaller than the original). Re-dimensioning arrays creates a big overload for the server, especially if you are also preserving its items. The only way of optimizing this is to try not to use it. Try to dimension your arrays from the declaration, and try as seldom as possible to re-dimension them.
  Optimizing memory and speed when working with Objects.
  Maybe the most useful optimization is achieved when object access is optimized. We use objects in almost all ASP pages, starting with database access objects, and finishing with custom-made objects. Everybody knows that programmers are inherently lazy. This fact can usually get us into trouble. From ASP, you have access to different objects, but the most used ones are the ones for database access (mostly ADO, or DAO) or MTS objects.
  The way you create the object is important because it can speed up, or slow down your ASP page. If you want to create objects that reside in the MTS environment, the best way

本文转自
http://study.qqcf.com/web/244/29547.htm
AI 代码审查Review工具 是一个旨在自动化代码审查流程的工具。它通过集成版本控制系统(如 GitHub GitLab)的 Webhook,利用大型语言模型(LLM)对代码变更进行分析,并将审查意见反馈到相应的 Pull Request 或 Merge Request 中。此外,它还支持将审查结果通知到企业微信等通讯工具。 一个基于 LLM 的自动化代码审查助手。通过 GitHub/GitLab Webhook 监听 PR/MR 变更,调用 AI 分析代码,并将审查意见自动评论到 PR/MR,同时支持多种通知渠道。 主要功能 多平台支持: 集成 GitHub GitLab Webhook,监听 Pull Request / Merge Request 事件。 智能审查模式: 详细审查 (/github_webhook, /gitlab_webhook): AI 对每个变更文件进行分析,旨在找出具体问题。审查意见会以结构化的形式(例如,定位到特定代码行、问题分类、严重程度、分析建议)逐条评论到 PR/MR。AI 模型会输出 JSON 格式的分析结果,系统再将其转换为多条独立的评论。 通用审查 (/github_webhook_general, /gitlab_webhook_general): AI 对每个变更文件进行整体性分析,并为每个文件生成一个 Markdown 格式的总结性评论。 自动化流程: 自动将 AI 审查意见(详细模式下为多条,通用模式下为每个文件一条)发布到 PR/MR。 在所有文件审查完毕后,自动在 PR/MR 中发布一条总结性评论。 即便 AI 未发现任何值得报告的问题,也会发布相应的友好提示总结评论。 异步处理审查任务,快速响应 Webhook。 通过 Redis 防止对同一 Commit 的重复审查。 灵活配置: 通过环境变量设置基
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值