不用dll http://www.ibeike.net/news/default.asp 15毫秒
用了dll http://www.ibeike.net/news/default_dll.asp85毫秒
郁闷大家有没有什么解释?
不用dll的ASP 15毫秒
1 @Language = "VBScript"
1 Option Explicit
1
2dim st
3st = timer
1
2'初始化系统
1<link href="admin/site.css" rel="stylesheet"/>
1
2function htmlencode(str)
3Dim result
4result = str
5if isNULL(str) then
6htmlencode=""
7exit function
8end if
9result = Server.HtmlEncode(result)
10result = Replace(result,"<","<")
11result = Replace(result,">",">")
12result = Replace(result,chr(13),"
``` ```
``` ") result = Replace(result," "," ") result = Replace(result,"'","'") htmlencode = result end function
1<!--#include file="inc/initsystem.inc" -->
本页为首页显示范例
``` ```
Dim SQL,Conn,Rs,maxpagesize
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Application("Connstr")
SQL = "Select * from config"
Set Rs = Conn.Execute(SQL)
maxpagesize = Cint(Rs("maxpagesizeindex"))
Rs.Close
Set Rs = Nothing
If Request("type") <> "" AND IsNumeric(Request("type")) = True then
SQL = "Select * from News Where Isdelete = 0 And newsType = "&Request("type")&" Order by NewsID Desc"
Else
SQL = "Select * from News Where Isdelete = 0 Order by NewsID Desc"
End if
Set Rs = Server.CreateObject("ADODB.RecordSet")
Rs.Open SQL,Conn,1,1
If Rs.Eof Then
Response.Write "现在还没有新闻"
Else
Dim i
i = 0
While Not( Rs.eof ) And i < maxpagesize
1·
<a =rs("newsid")="" ="" class="01" href="show.asp?id=
" title='作者:```
=Rs("anthor")
1=vbcrlf
2```发表日期:```
3=Rs("updatetime")
4```'>```
5=htmlencode(Rs("title"))
6```</a>
7```
8```
9if instr(Rs("content"),"") > 0 then
10```
11```
12<img src="images/photo.jpg"/>
13```
14```
15end if
16```
17```
18<br/>
19```
20```
21 Rs.MoveNext
22i = i + 1
23Wend
24End if
25
26```
27```
28<br/>
29```
30```
31
32Rs.Close
33SQL = "Select * from Newstype"
34Set Rs = Conn.Execute(SQL)
35While Not Rs.Eof
36
37```[
38```
39<a ```"="" class="01" href="default.asp?type=```
40=Rs(" typeid")="">```
41=Rs("newsType")
42```</a>
43```
44]```
45
46Rs.Movenext
47Wend
48Rs.Close
49Set Rs = Nothing
50Conn.Close
51Set Conn = Nothing
52
53```
54```
55<br/>
56```
57```
58<br/>
59```
60```
61<br/>
62```
63```
64<a class="01" href="more.asp"><font color="red">MORE 显示效果</font></a>
65```
66```
67<br/>
68```
69```
70<br/>
71```
72```
73
74dim ed
75ed = timer
76response.write" 页面执行时间:"&FormatNumber((ed-st)*1000,3)&"毫秒"
77
78```
79
80用了dll85毫秒
81```
82 @Language = "VBScript"
83```
84```
85 Option Explicit
86```
87```
88
89dim st
90st = timer
91
92```
93```
94
95'初始化系统
96
97```
98```
99<link href="admin/site.css" rel="stylesheet"/>
100```
101<!--#include file="inc/searchstring.inc" -->
102<!--#include file="inc/initsystem.inc" -->
103```
104<font color="red"><h3>本页为首页显示范例</h3></font>
105```
106```
107<br/>
108```
109```
110
111Dim NewsSys
112Set NewsSys = Server.CreateObject("Hostx.news")
113NewsSys.IndexNews()
114NewsSys.Showtype()
115Set NewsSys = Nothing
116
117```
118```
119<br/>
120```
121```
122<br/>
123```
124```
125<br/>
126```
127```
128<a class="01" href="more.asp"><font color="red">MORE 显示效果</font></a>
129```
130```
131<br/>
132```
133```
134<br/>
135```
136```
137
138dim ed
139ed = timer
140response.write" 页面执行时间:"&FormatNumber((ed-st)*1000,3)&"毫秒"
141
142```
143
144
145这个是dll的源代码
146大家看看
147
148'对象的声明
149Private ScriptingContext As ScriptingContext
150Private Response As Response
151Private Request As Request
152Private Application As Application
153Private Server As Server
154Private Session As Session
155Public Conn As New ADODB.Connection
156Public Rs As New ADODB.Recordset
157
158'当组件被创建的时候会触发这个事件
159Public Sub OnStartPage(ScriptingContext As ScriptingContext)
160'进行对象的实例化
161Set Response = ScriptingContext.Response
162Set Request = ScriptingContext.Request
163Set Server = ScriptingContext.Server
164Set Application = ScriptingContext.Application
165Set Session = ScriptingContext.Session
166Conn.Open Application("Connstr")
167End Sub
168
169'当组件被销毁的时候触发这个事件
170Public Sub OnEndPage()
171Conn.Close
172Set Rs = Nothing
173Set Conn = Nothing
174'销毁对象
175Set Response = Nothing
176Set Request = Nothing
177Se
178\---------------------------------------------------------------
179
180哈哈,给分了
181在少量ASP代码被封装进 COM 对象时,可能不会使性能有所改进,反而会引起性能下降。这种情况通常是创建和调用 COM 对象的系统开销超过了编译代码的系统开销