always there for you

善于生活,善于学习,这是我和你的目标.

« asp.net(C#)面试题 用VB编写ActiveX DLL实现ASP编程 »

大量服务器脚本输出与混合输出的性能比较-asp

  昨天看到起步者的留言,才猛然想到自己已经很久没用过VS了,早上又去了微软发现现在有Visual Studio 2008试用版(90天)下载.

  因为太大了,而且我也用不着那么多功能,所以找到了Visual Web Developer 2008 Express Edition,专门做asp.net,(可以申请注册).

  在下载的这段时间,便想利用昨天写的TestTime类来比较下混合脚本和Html与单服务器脚本的性能,以下是测试内容!

<%

'--清除缓存
  Response.Buffer = True
 Response.ExpiresAbsolute = Now() - 1
 Response.Expires = 0
 Response.CacheControl = "no-cache"
 Response.AddHeader "Pragma", "No-Cache"


 Class TestTime
   Dim StartTime
   Dim EndTime
  
   Public Function Start()
     StartTime = timer()
   End Function
  
   Public Function Ends()    
     EndTime = timer()
     Ends = FormatNumber((EndTime-StartTime)*1000,3)&"毫秒"
     End Function    
 End Class
 
 '--声明TestTime类的一个实例
 Set oTestTime = New TestTime
 Dim str1,str2    '--用于存储两次的结果
 
 '--测试单服务器脚本输出
 oTestTime.Start()
 For i=0 to 100000
  Response.Write "-"
 Next
 oTestTime.Ends()
 str1 = oTestTime.Ends
 

'--测试混合语言输出
 oTestTime.Start()
 For i=0 to 100000
%>
  -
<%
 Next
 oTestTime.Ends()
 str2 = oTestTime.Ends
 
 Response.Write "<br />"
 Response.Write "单服务器语言所花时间:"&str1&"<br />"
 Response.Write "混合语言所花时间:"&str2&"<br />"
 
 '--当输出10万字符时,才出现15-30几毫秒的差距,可见使用这两种方法效率不相上下
%>

 

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Copyright www.alwaysthere.com.cn . Some Rights Reserved.

              

Powered By Z-Blog 1.8 Devo Build 80201